Skip to content

Commit

Permalink
update script index
Browse files Browse the repository at this point in the history
  • Loading branch information
ktKongTong committed Apr 15, 2024
1 parent 5feba7b commit b58e29b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions script/parse/frontmatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ export async function extractFrontMatter(source:cheerio.Root,option:Options):Pro
LogToInfo(`标题格式错误:${sourceTitle},无法提取索引`)
}
}
if(index?.includes(".5")) {
index = parseInt(index.replace(".5","")).toString().padStart(4,'0') + "_5"
}else {
index = parseInt(index!).toString().padStart(4,'0')
}

title = option.title ? option.title : `【${catagory}${index}${title.trim()}`
let description = ""
if (option.bv !== undefined) {
Expand Down
7 changes: 6 additions & 1 deletion script/utils/frontmatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ export async function buildFrontmatter(source:SourceInfo,options:Options):Promis
if(options.category) {
catagory = options.category
}
let indexPattern = /\d{1,4}/
let indexPattern = /\d{1,4}(\.5)?/
let index = source.title.match(indexPattern)?.["0"]
if (!index) {
index = options.index??"1"
if (options.ghac) {
LogToInfo(`标题格式错误:${source.title},无法提取索引`)
}
}
if(index?.includes(".5")) {
index = parseInt(index.replace(".5","")).toString().padStart(4,'0') + "_5"
}else {
index = parseInt(index!).toString().padStart(4,'0')
}
title = `【${catagory}${index}${title}`
let description = ""
if (options.bv !== undefined) {
Expand Down

0 comments on commit b58e29b

Please sign in to comment.