Skip to content

Commit

Permalink
chore: add search
Browse files Browse the repository at this point in the history
  • Loading branch information
DaiQiangReal committed Mar 24, 2022
1 parent 20f8115 commit 21329c8
Show file tree
Hide file tree
Showing 16 changed files with 5 additions and 1,149 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ server/view/
.expo/

# json
static/search_data_client.json
search/data_client.json
static/changeLog.json
static/designToken.json

Expand Down Expand Up @@ -226,4 +224,4 @@ fastlane/readme.md
tmp

# test
/__snapshots__/
/__snapshots__/
31 changes: 1 addition & 30 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');

const path = require('path');
const fs = require('fs');
const processGraphQLData = require('./search/generator');
const items = ['basic', 'chart'];
const sha1 = require('sha1');
const hash = sha1(`${new Date().getTime()}${Math.random()}`);
Expand Down Expand Up @@ -179,6 +178,7 @@ exports.onCreateWebpackConfig = ({ stage, rules, loaders, plugins, actions }) =>
},
plugins: [plugins.extractText(),plugins.define({
"THEME_SWITCHER_URL":JSON.stringify(process.env['THEME_SWITCHER_URL']),
"SEMI_SEARCH_URL":JSON.stringify(process.env['SEMI_SEARCH_URL']),
"DSM_URL":JSON.stringify(process.env['DSM_URL']),
'process.env.SEMI_SITE_HEADER':JSON.stringify(process.env.SEMI_SITE_HEADER),
'process.env.SEMI_SITE_BANNER':JSON.stringify(process.env.SEMI_SITE_BANNER),
Expand Down Expand Up @@ -232,35 +232,6 @@ exports.createPages = async ({ actions, graphql, reporter }) => {

const blogPostTemplate = path.resolve('src/templates/postTemplate.js');

// 开始处理搜索数据
// console.log('building search data.');
const searchData = await graphql(`
query MyQuery {
allMdx {
nodes {
id
fields {
slug
type
typeOrder
}
frontmatter {
brief
localeCode
title
}
tableOfContents
mdxAST
}
}
}`);

// 在此你可以处理searchData(GraphQL查询的raw数据) 或者传入回调 处理运算后的数据
processGraphQLData(searchData, processedData => {});
// 搜索有用到,但是目前没有搜索,先注释掉,不然影响文档站的本地调试
// fs.copyFileSync('./search/data_client.json', './static/search_data_client.json');
// console.log('building search data success.')
// 搜索数据处理结束
const result = await graphql(`
query {
allMdx(
Expand Down
225 changes: 0 additions & 225 deletions search/generator.js

This file was deleted.

68 changes: 0 additions & 68 deletions search/searchDemo.js

This file was deleted.

Loading

0 comments on commit 21329c8

Please sign in to comment.