website: fix search data error. #105 #32

This commit is contained in:
jaywcjlove
2022-11-17 17:08:26 +08:00
parent 7479c1045c
commit 764b55045d
2 changed files with 15 additions and 7 deletions

View File

@ -89,12 +89,18 @@ export function create(str = '', options = {}) {
if (!options.isHome) {
const tocsMenus = getTocsTitleNode([...tocsData]);
node.children = addTocsInWarp([...tocsData], getTocsTitleNodeWarpper(tocsMenus));
tocsMenus.forEach((menu) => {
detailData.sections.push({
a: menu?.properties?.href,
t: getCodeString(menu.children),
l: menu?.properties['data-num'],
});
tocsMenus.forEach((menu, idx) => {
const level = menu?.properties['data-num'];
if (idx + 1 === tocsMenus.length && level === 2) {
return;
}
if (level < 4) {
detailData.sections.push({
a: menu?.properties?.href,
t: getCodeString(menu.children),
l: menu?.properties['data-num'],
});
}
});
} else {
node.children = tocsData;