先修复一下路径

This commit is contained in:
RickCole21 2020-08-21 15:07:13 +08:00
parent 625cfb75de
commit b26f4d3e97
3 changed files with 592 additions and 4 deletions

View File

@ -30,9 +30,8 @@ glob('./docs/**/*.md', {}, function (er, docs) {
.replace(/!?\[.*\]\(.*\)/g, '') .replace(/!?\[.*\]\(.*\)/g, '')
.replace(/\n/g, '') .replace(/\n/g, '')
.replace(/```.*```/g, '') .replace(/```.*```/g, '')
.toLowerCase(), .toLowerCase(),
path: doc.replace('.md', '') path: doc.slice(1).replace('.md', '')
}); });
} }
fs.writeFileSync('./examples/docs.json', JSON.stringify(resultData)); fs.writeFileSync('./examples/docs.json', JSON.stringify(resultData));

View File

@ -5,6 +5,12 @@ import React from 'react';
import Axios from 'axios'; import Axios from 'axios';
import SearchBox from '../../src/components/SearchBox'; import SearchBox from '../../src/components/SearchBox';
let ContextPath = '';
if (process.env.NODE_ENV === 'production') {
ContextPath = '/amis';
}
export default class DocSearch extends React.Component { export default class DocSearch extends React.Component {
docs = []; docs = [];
constructor(props) { constructor(props) {
@ -74,7 +80,7 @@ export default class DocSearch extends React.Component {
<div className="search-result"> <div className="search-result">
{searchResults.map(item => { {searchResults.map(item => {
return ( return (
<a href={'/' + item.path} key={`list_${item.path}`}> <a href={ContextPath + item.path} key={`list_${item.path}`}>
<h5>{item.title}</h5> <h5>{item.title}</h5>
<p dangerouslySetInnerHTML={{__html: item.abstract}} /> <p dangerouslySetInnerHTML={{__html: item.abstract}} />
</a> </a>

File diff suppressed because one or more lines are too long