|
2 | 2 | """生成《高性价比工作指南》导航页 index.html(自包含,无外部依赖)""" |
3 | 3 | import json, html |
4 | 4 |
|
| 5 | +# 动态统计:章数与条目数(标题/描述里用,避免写死) |
| 6 | +try: |
| 7 | + NCH = len(json.load(open("data/chapters.json", encoding="utf-8"))) |
| 8 | +except Exception: |
| 9 | + NCH = 50 |
| 10 | +try: |
| 11 | + _it = json.load(open("data/items.json", encoding="utf-8")) |
| 12 | + NIT = len(_it) if isinstance(_it, list) else len(_it.get("items", [])) |
| 13 | +except Exception: |
| 14 | + NIT = 0 |
| 15 | + |
5 | 16 | BASE = 'https://github.com/NiceCao/HowToWorkBetter/blob/main/book/' |
6 | 17 | BASECH = 'ch/' |
7 | 18 | ch = {c['n']: c for c in json.load(open('data/chapters.json', encoding='utf-8'))} |
@@ -113,18 +124,18 @@ def chips(group, label, options): |
113 | 124 | <head> |
114 | 125 | <meta charset="utf-8"> |
115 | 126 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
116 | | -<title>《高性价比工作指南》· 50 章 416 条,按阶段、职业和板块找建议</title> |
117 | | -<meta name="description" content="写给普通打工人的工作指南:50 章、416 条建议,每条写明要花掉什么、能换回什么、证据有多硬。可以按你现在在哪一步、你是做什么的、或按板块找。"> |
| 127 | +<title>《高性价比工作指南》· {NCH} 章 {NIT} 条,按阶段、职业和板块找建议</title> |
| 128 | +<meta name="description" content="写给普通打工人的工作指南:{NCH} 章、{NIT} 条建议,每条写明要花掉什么、能换回什么、证据有多硬。可以按你现在在哪一步、你是做什么的、或按板块找。"> |
118 | 129 | <link rel="canonical" href="https://nicecao.github.io/HowToWorkBetter/"> |
119 | 130 | <meta property="og:type" content="website"> |
120 | | -<meta property="og:title" content="高性价比工作指南 · 50 章 416 条"> |
| 131 | +<meta property="og:title" content="高性价比工作指南 · {NCH} 章 {NIT} 条"> |
121 | 132 | <meta property="og:description" content="每条建议都写明要花掉什么、能换回什么、证据有多硬;按阶段、按职业、按板块都能找。"> |
122 | 133 | <meta property="og:url" content="https://nicecao.github.io/HowToWorkBetter/"> |
123 | 134 | <meta property="og:image" content="https://nicecao.github.io/HowToWorkBetter/og.png"> |
124 | 135 | <meta name="twitter:card" content="summary_large_image"> |
125 | 136 | <script type="application/ld+json"> |
126 | 137 | {{"@context":"https://schema.org","@type":"Book","name":"高性价比工作指南", |
127 | | -"description":"写给普通打工人的工作指南,50 章 416 条建议,每条写明成本、收益和证据等级。", |
| 138 | +"description":"写给普通打工人的工作指南,{NCH} 章 {NIT} 条建议,每条写明成本、收益和证据等级。", |
128 | 139 | "inLanguage":"zh-CN","url":"https://nicecao.github.io/HowToWorkBetter/", |
129 | 140 | "image":"https://nicecao.github.io/HowToWorkBetter/og.png", |
130 | 141 | "author":{{"@type":"Person","name":"作者"}},"license":"https://creativecommons.org/licenses/by/4.0/"}} |
|
0 commit comments