11import { observer } from 'mobx-react' ;
22import { GetStaticProps } from 'next' ;
3- import Link from 'next/link' ;
43import React , { FC , useContext } from 'react' ;
5- import { Badge , Button , Card , Container } from 'react-bootstrap' ;
4+ import { Button , Card , Container } from 'react-bootstrap' ;
65import { treeFrom } from 'web-utility' ;
76
7+ import { ContentTree } from '../../components/Layout/ContentTree' ;
88import { PageHead } from '../../components/Layout/PageHead' ;
99import { I18nContext } from '../../models/Translation' ;
1010import { recipeContentStore , XContent } from '../../models/Wiki' ;
@@ -25,32 +25,6 @@ export const getStaticProps: GetStaticProps<{ nodes: XContent[] }> = async () =>
2525 } ;
2626} ;
2727
28- const renderTree = ( nodes : XContent [ ] , level = 0 ) => (
29- < ol className = { level === 0 ? 'list-unstyled' : '' } >
30- { nodes . map ( ( { path, name, type, meta, children } ) => (
31- < li key = { path } className = { level > 0 ? 'ms-3' : '' } >
32- { type !== 'dir' ? (
33- < Link className = "h4 d-flex align-items-center py-1" href = { `/recipes/${ path } ` } >
34- { name }
35-
36- { meta ?. [ 'category' ] && (
37- < Badge bg = "secondary" className = "ms-2 small" >
38- { meta [ 'category' ] }
39- </ Badge >
40- ) }
41- </ Link >
42- ) : (
43- < details >
44- < summary className = "h4" > { name } </ summary >
45-
46- { renderTree ( children || [ ] , level + 1 ) }
47- </ details >
48- ) }
49- </ li >
50- ) ) }
51- </ ol >
52- ) ;
53-
5428const RecipeIndexPage : FC < { nodes : XContent [ ] } > = observer ( ( { nodes } ) => {
5529 const { t } = useContext ( I18nContext ) ;
5630
@@ -72,8 +46,25 @@ const RecipeIndexPage: FC<{ nodes: XContent[] }> = observer(({ nodes }) => {
7246 </ Button >
7347 </ hgroup >
7448
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 >
61+
7562 { nodes [ 0 ] ? (
76- renderTree ( treeFrom ( nodes , 'path' , 'parent_path' , 'children' ) )
63+ < ContentTree
64+ nodes = { treeFrom ( nodes , 'path' , 'parent_path' , 'children' ) }
65+ basePath = "/recipes"
66+ metaKey = "category"
67+ />
7768 ) : (
7869 < Card >
7970 < Card . Body className = "text-muted text-center" >
0 commit comments