File tree Expand file tree Collapse file tree 2 files changed +22
-24
lines changed
Expand file tree Collapse file tree 2 files changed +22
-24
lines changed Original file line number Diff line number Diff line change @@ -16,12 +16,16 @@ def load_json(file_path):
1616 return data
1717
1818def get_site_template ():
19- info = load_json ('info.json' )
20- template = info ['project' ] | parse_yaml (os .path .join (script_dir , "template.yml" ))
21- template ['extra' ] = info ['extra' ]
22- template ['nav' ] = { '简介' : info ['front' ] }
23- template ['nav' ] += [{item ['title' ]: item ['children' ]} for item in info ['nav' ]]
24- return template
19+ info = load_json (script_dir / 'info.json' )
20+ template_defaults = parse_yaml (script_dir / 'template.yml' )
21+
22+ nav = [{'简介' : info ['front' ]}]
23+ nav .extend ({item ['title' ]: item ['children' ]} for item in info ['nav' ])
24+
25+ return info ['project' ] | template_defaults | {
26+ 'extra' : info ['extra' ],
27+ 'nav' : nav
28+ }
2529
2630if __name__ == "__main__" :
2731 with open ('mkdocs.yml' , 'w' , encoding = 'utf-8' ) as file :
Original file line number Diff line number Diff line change @@ -15,25 +15,19 @@ def load_json(file_path):
1515 data = json .load (file )
1616 return data
1717
18- intro = [
19- {
20- '简介' : [
21- 'index.md' ,
22- 'intro/format.md' ,
23- 'intro/usage.md' ,
24- 'intro/discussion.md' ,
25- 'madoka.md'
26- ]
27- }
28- ]
29-
3018def get_site_template ():
31- info = load_json ('info.json' )
32- template = info ['project' ] | parse_yaml (os .path .join (script_dir , "template.serve.yml" ))
33- template ['nav' ] = { '简介' : info ['front' ] }
34- template ['nav' ] += [{item ['title' ]: item ['children' ]} for item in info ['nav' ]]
35- del (template ['site_url' ])
36- return template
19+ info = load_json (script_dir / 'info.json' )
20+ del (info ['project' ]['site_url' ])
21+
22+ template_defaults = parse_yaml (script_dir / 'template.serve.yml' )
23+
24+ nav = [{'简介' : info ['front' ]}]
25+ nav .extend ({item ['title' ]: item ['children' ]} for item in info ['nav' ])
26+
27+ return info ['project' ] | template_defaults | {
28+ 'extra' : info ['extra' ],
29+ 'nav' : nav
30+ }
3731
3832if __name__ == "__main__" :
3933 with open ('mkdocs.yml' , 'w' , encoding = 'utf-8' ) as file :
You can’t perform that action at this time.
0 commit comments