Skip to content

Commit 5f080f1

Browse files
committed
Update
1 parent 0e05e09 commit 5f080f1

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

scripts/generate.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ def load_json(file_path):
1616
return data
1717

1818
def 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

2630
if __name__ == "__main__":
2731
with open('mkdocs.yml', 'w', encoding='utf-8') as file:

scripts/generate.serve.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff 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-
3018
def 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

3832
if __name__ == "__main__":
3933
with open('mkdocs.yml', 'w', encoding='utf-8') as file:

0 commit comments

Comments
 (0)