1
1
import { observer } from 'mobx-react' ;
2
2
import { GetStaticProps } from 'next' ;
3
3
import React , { FC , useContext } from 'react' ;
4
- import { Button , Card , Container } from 'react-bootstrap' ;
4
+ import { Alert , Button , Card , Container } from 'react-bootstrap' ;
5
5
import { treeFrom } from 'web-utility' ;
6
6
7
7
import { ContentTree } from '../../components/Layout/ContentTree' ;
8
8
import { PageHead } from '../../components/Layout/PageHead' ;
9
9
import { I18nContext } from '../../models/Translation' ;
10
10
import { recipeContentStore , XContent } from '../../models/Wiki' ;
11
- import { MD_pattern , splitFrontMatter } from '../api/core' ;
11
+ import { filterMarkdownFiles } from '../api/core' ;
12
12
13
13
export 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 ( ) ) ;
21
15
22
16
return {
23
17
props : JSON . parse ( JSON . stringify ( { nodes } ) ) ,
@@ -30,11 +24,11 @@ const RecipeIndexPage: FC<{ nodes: XContent[] }> = observer(({ nodes }) => {
30
24
31
25
return (
32
26
< Container className = "py-4" >
33
- < PageHead title = { `${ t ( 'recipes ' ) } - ${ t ( 'knowledge_base' ) } ` } />
27
+ < PageHead title = { `${ t ( 'recipe ' ) } - ${ t ( 'knowledge_base' ) } ` } />
34
28
35
29
< hgroup className = "d-flex justify-content-between align-items-center mb-4" >
36
30
< h1 >
37
- { t ( 'recipes ' ) } ({ nodes . length } )
31
+ { t ( 'recipe ' ) } ({ nodes . length } )
38
32
</ h1 >
39
33
< Button
40
34
href = "https://github.com/Gar-b-age/CookLikeHOC"
@@ -46,23 +40,22 @@ const RecipeIndexPage: FC<{ nodes: XContent[] }> = observer(({ nodes }) => {
46
40
</ Button >
47
41
</ hgroup >
48
42
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 >
61
54
62
55
{ 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 "
66
59
metaKey = "category"
67
60
/>
68
61
) : (
@@ -77,4 +70,4 @@ const RecipeIndexPage: FC<{ nodes: XContent[] }> = observer(({ nodes }) => {
77
70
) ;
78
71
} ) ;
79
72
80
- export default RecipeIndexPage ;
73
+ export default RecipeIndexPage ;
0 commit comments