11import { observer } from 'mobx-react' ;
22import { GetStaticProps } from 'next' ;
33import React , { FC , useContext } from 'react' ;
4- import { Button , Card , Container } from 'react-bootstrap' ;
4+ import { Alert , Button , Card , Container } from 'react-bootstrap' ;
55import { treeFrom } from 'web-utility' ;
66
77import { ContentTree } from '../../components/Layout/ContentTree' ;
88import { PageHead } from '../../components/Layout/PageHead' ;
99import { I18nContext } from '../../models/Translation' ;
1010import { recipeContentStore , XContent } from '../../models/Wiki' ;
11- import { MD_pattern , splitFrontMatter } from '../api/core' ;
11+ import { filterMarkdownFiles } from '../api/core' ;
1212
1313export const getStaticProps : GetStaticProps < { nodes : XContent [ ] } > = async ( ) => {
14- const nodes = ( await recipeContentStore . getAll ( ) )
15- . filter ( ( { type, name } ) => type !== 'file' || MD_pattern . test ( name ) )
16- . map ( ( { content, ...rest } ) => {
17- const { meta, markdown } = content ? splitFrontMatter ( content ) : { } ;
18-
19- return { ...rest , content : markdown , meta } ;
20- } ) ;
14+ const nodes = filterMarkdownFiles ( await recipeContentStore . getAll ( ) ) ;
2115
2216 return {
2317 props : JSON . parse ( JSON . stringify ( { nodes } ) ) ,
@@ -30,11 +24,11 @@ const RecipeIndexPage: FC<{ nodes: XContent[] }> = observer(({ nodes }) => {
3024
3125 return (
3226 < Container className = "py-4" >
33- < PageHead title = { `${ t ( 'recipes ' ) } - ${ t ( 'knowledge_base' ) } ` } />
27+ < PageHead title = { `${ t ( 'recipe ' ) } - ${ t ( 'knowledge_base' ) } ` } />
3428
3529 < hgroup className = "d-flex justify-content-between align-items-center mb-4" >
3630 < h1 >
37- { t ( 'recipes ' ) } ({ nodes . length } )
31+ { t ( 'recipe ' ) } ({ nodes . length } )
3832 </ h1 >
3933 < Button
4034 href = "https://github.com/Gar-b-age/CookLikeHOC"
@@ -46,23 +40,22 @@ const RecipeIndexPage: FC<{ nodes: XContent[] }> = observer(({ nodes }) => {
4640 </ Button >
4741 </ hgroup >
4842
49- < div className = "alert alert-info mb-4" role = "alert" >
50- < p className = "mb-1" >
51- < strong > 感谢老乡鸡餐饮公司及开源菜谱仓库原作者</ strong >
52- </ p >
53- < p className = "mb-0" >
54- 本菜谱内容来自{ ' ' }
55- < a href = "https://github.com/Gar-b-age/CookLikeHOC" target = "_blank" rel = "noopener noreferrer" >
56- CookLikeHOC 开源菜谱项目
57- </ a >
58- ,感谢原作者们的贡献与分享。
59- </ p >
60- </ div >
43+ < Alert variant = "info" className = "mb-4" >
44+ 本菜谱原创自
45+ < Alert . Link href = "https://www.lxjchina.com.cn/display_4226.html" target = "_blank" >
46+ 《老乡鸡菜品溯源报告》
47+ </ Alert . Link >
48+ ,并由{ ' ' }
49+ < Alert . Link href = "https://github.com/Gar-b-age/CookLikeHOC" target = "_blank" >
50+ CookLikeHOC 开源菜谱项目
51+ </ Alert . Link >
52+ 整理,感谢原作者们的贡献与分享。
53+ </ Alert >
6154
6255 { nodes [ 0 ] ? (
63- < ContentTree
64- nodes = { treeFrom ( nodes , 'path' , 'parent_path' , 'children' ) }
65- basePath = "/recipes "
56+ < ContentTree
57+ nodes = { treeFrom ( nodes , 'path' , 'parent_path' , 'children' ) }
58+ basePath = "/recipe "
6659 metaKey = "category"
6760 />
6861 ) : (
@@ -77,4 +70,4 @@ const RecipeIndexPage: FC<{ nodes: XContent[] }> = observer(({ nodes }) => {
7770 ) ;
7871} ) ;
7972
80- export default RecipeIndexPage ;
73+ export default RecipeIndexPage ;
0 commit comments