mirror of
https://github.com/jaywcjlove/reference.git
synced 2025-06-17 04:31:22 +08:00
feat: add http-status-code.md
cheatsheet.
This commit is contained in:
18
scripts/utils/panelAddNumber.mjs
Normal file
18
scripts/utils/panelAddNumber.mjs
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
/** 标记 Number */
|
||||
export function panelAddNumber(arr = [], result = []) {
|
||||
let n = 0;
|
||||
let level = -1;
|
||||
while (n < arr.length) {
|
||||
const toc = arr[n];
|
||||
const titleNum = Number(toc?.tagName?.replace(/^h/, ''));
|
||||
if (titleNum && titleNum > -1) {
|
||||
level = titleNum;
|
||||
}
|
||||
if (toc) {
|
||||
result.push({ ...toc, number: level })
|
||||
}
|
||||
n++;
|
||||
}
|
||||
return result
|
||||
}
|
Reference in New Issue
Block a user