mirror of
https://github.com/jaywcjlove/reference.git
synced 2025-06-16 20:21:22 +08:00
feat: add http-status-code.md
cheatsheet.
This commit is contained in:
18
scripts/utils/childs.mjs
Normal file
18
scripts/utils/childs.mjs
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
export function getChilds(data = [], level, result = []) {
|
||||
for (let i = 1; i <= data.length; i++) {
|
||||
const titleNum = Number(data[i]?.tagName?.replace(/^h/, ''));
|
||||
if (titleNum && titleNum === level) break;
|
||||
result.push(data[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 获取 Heading 到下一个 Heading 之间的内容*/
|
||||
export function getHeader(data = [], level, result = []) {
|
||||
for (let i = 1; i <= data.length; i++) {
|
||||
if (/^h\d$/.test(data[i]?.tagName) || data[i]?.number !== level) break;
|
||||
result.push(data[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
Reference in New Issue
Block a user