Skip to content

Commit d4bb097

Browse files
committedDec 5, 2021
feat: 生成 toc 显示题目网页序号
1 parent b25eee7 commit d4bb097

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed
 

‎cmd/update/main.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var (
2424
tagsRegex = regexp.MustCompile("@tags (.+)")
2525
draftRegex = regexp.MustCompile("@draft (.+)")
2626
linkRegex = regexp.MustCompile("@link (.+)")
27+
frontendIdRegex = regexp.MustCompile("@frontendId (.+)")
2728
)
2829

2930
var (
@@ -38,6 +39,7 @@ type Meta struct {
3839
Draft bool
3940
Fp string
4041
Link string
42+
FrontendId string
4143
}
4244

4345
type Metas []*Meta
@@ -92,6 +94,7 @@ func findMeta(content []byte, fp string) *Meta {
9294
Draft: draft,
9395
Fp: filepath.Dir(fp),
9496
Link: findTag(content, linkRegex),
97+
FrontendId: findTag(content, frontendIdRegex),
9598
}
9699
}
97100

@@ -179,7 +182,7 @@ var tableStr = `
179182
180183
总计: {{ .Total }}
181184
182-
| 序号 | 难度 | 题目 | 解答 |
183-
| ---- | ---- | ------------------ | ---------------- |{{ range .Metas }}
184-
| {{ .Index }} | {{ .Difficulty }} | [{{ .Title }}]({{ .Link }}) | [{{ .Fp }}](../{{ .Fp }})|{{ end }}
185+
| 网页序号 | 序号 | 难度 | 题目 | 解答 |
186+
| ---- | ---- | ---- | ------------------ | ---------------- |{{ range .Metas }}
187+
| {{ .FrontendId }} | {{ .Index }} | {{ .Difficulty }} | [{{ .Title }}]({{ .Link }}) | [{{ .Fp }}](../{{ .Fp }})|{{ end }}
185188
`

0 commit comments

Comments
 (0)