Skip to content

Commit 6a71ddf

Browse files
committed
检索页与来源对照表的章数/条数改为动态统计(并入后 436 条,不再写死 416)
1 parent c99f36b commit 6a71ddf

4 files changed

Lines changed: 22 additions & 11 deletions

File tree

‎build_index.py‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22
"""生成《高性价比工作指南》导航页 index.html(自包含,无外部依赖)"""
33
import json, html
44

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+
516
BASE = 'https://github.com/NiceCao/HowToWorkBetter/blob/main/book/'
617
BASECH = 'ch/'
718
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):
113124
<head>
114125
<meta charset="utf-8">
115126
<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} 条建议,每条写明要花掉什么、能换回什么、证据有多硬。可以按你现在在哪一步、你是做什么的、或按板块找。">
118129
<link rel="canonical" href="https://nicecao.github.io/HowToWorkBetter/">
119130
<meta property="og:type" content="website">
120-
<meta property="og:title" content="高性价比工作指南 · 50 章 416 条">
131+
<meta property="og:title" content="高性价比工作指南 · {NCH} 章 {NIT} 条">
121132
<meta property="og:description" content="每条建议都写明要花掉什么、能换回什么、证据有多硬;按阶段、按职业、按板块都能找。">
122133
<meta property="og:url" content="https://nicecao.github.io/HowToWorkBetter/">
123134
<meta property="og:image" content="https://nicecao.github.io/HowToWorkBetter/og.png">
124135
<meta name="twitter:card" content="summary_large_image">
125136
<script type="application/ld+json">
126137
{{"@context":"https://schema.org","@type":"Book","name":"高性价比工作指南",
127-
"description":"写给普通打工人的工作指南,50 章 416 条建议,每条写明成本、收益和证据等级。",
138+
"description":"写给普通打工人的工作指南,{NCH} 章 {NIT} 条建议,每条写明成本、收益和证据等级。",
128139
"inLanguage":"zh-CN","url":"https://nicecao.github.io/HowToWorkBetter/",
129140
"image":"https://nicecao.github.io/HowToWorkBetter/og.png",
130141
"author":{{"@type":"Person","name":"作者"}},"license":"https://creativecommons.org/licenses/by/4.0/"}}

‎docs/引用对照.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 引用对照表(416 条建议 · 逐条来源)
1+
# 引用对照表(436 条建议 · 逐条来源)
22

33
本文件由 `tools/build_refs.py` 生成,请勿手改;重复运行结果一致(幂等)。
44
把每条建议「来源:」里列出的引用摊开,便于人工核对「这条的引用能不能证明这条论点」。

‎index.html‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1">
6-
<title>《高性价比工作指南》· 50 章 416 条,按阶段、职业和板块找建议</title>
7-
<meta name="description" content="写给普通打工人的工作指南:50 章、416 条建议,每条写明要花掉什么、能换回什么、证据有多硬。可以按你现在在哪一步、你是做什么的、或按板块找。">
6+
<title>《高性价比工作指南》· 50 章 436 条,按阶段、职业和板块找建议</title>
7+
<meta name="description" content="写给普通打工人的工作指南:50 章、436 条建议,每条写明要花掉什么、能换回什么、证据有多硬。可以按你现在在哪一步、你是做什么的、或按板块找。">
88
<link rel="canonical" href="https://nicecao.github.io/HowToWorkBetter/">
99
<meta property="og:type" content="website">
10-
<meta property="og:title" content="高性价比工作指南 · 50 章 416 条">
10+
<meta property="og:title" content="高性价比工作指南 · 50 章 436 条">
1111
<meta property="og:description" content="每条建议都写明要花掉什么、能换回什么、证据有多硬;按阶段、按职业、按板块都能找。">
1212
<meta property="og:url" content="https://nicecao.github.io/HowToWorkBetter/">
1313
<meta property="og:image" content="https://nicecao.github.io/HowToWorkBetter/og.png">
1414
<meta name="twitter:card" content="summary_large_image">
1515
<script type="application/ld+json">
1616
{"@context":"https://schema.org","@type":"Book","name":"高性价比工作指南",
17-
"description":"写给普通打工人的工作指南,50 章 416 条建议,每条写明成本、收益和证据等级。",
17+
"description":"写给普通打工人的工作指南,50 章 436 条建议,每条写明成本、收益和证据等级。",
1818
"inLanguage":"zh-CN","url":"https://nicecao.github.io/HowToWorkBetter/",
1919
"image":"https://nicecao.github.io/HowToWorkBetter/og.png",
2020
"author":{"@type":"Person","name":"作者"},"license":"https://creativecommons.org/licenses/by/4.0/"}

‎tools/build_refs.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
3-
"""生成 docs/引用对照.md —— 《高性价比工作指南》416 条建议的逐条来源对照表。
3+
"""生成 docs/引用对照.md —— 《高性价比工作指南》逐条来源对照表(条数按实际统计)。
44
55
把每条建议「来源:」里列出的引用摊开(机构/文件名 + 链接),按章分组,
66
便于人工一眼看出「这条的引用能不能证明这条论点」。
@@ -162,7 +162,7 @@ def main():
162162
sections.append("## {}\n\n{}\n".format(heading, "\n".join(ch_lines)))
163163

164164
header = []
165-
header.append("# 引用对照表(416 条建议 · 逐条来源)\n")
165+
header.append(f"# 引用对照表({total_items} 条建议 · 逐条来源)\n")
166166
header.append("本文件由 `tools/build_refs.py` 生成,请勿手改;重复运行结果一致(幂等)。")
167167
header.append("把每条建议「来源:」里列出的引用摊开,便于人工核对"
168168
"「这条的引用能不能证明这条论点」。\n")

0 commit comments

Comments
 (0)