website: add search data. #105

This commit is contained in:
jaywcjlove
2022-11-17 15:58:53 +08:00
parent 599215755f
commit b034d7970d
4 changed files with 42 additions and 7 deletions

View File

@ -10,7 +10,12 @@ export function getTocsTitleNode(arr = [], result = []) {
arr.forEach(({ tagName, type, properties, children }) => {
if (/^h[23456]/.test(tagName)) {
const num = titleNum(tagName);
const props = { 'aria-hidden': 'true', class: `leve${num} tocs-link`, href: '#' + (properties.id || '') };
const props = {
'aria-hidden': 'true',
class: `leve${num} tocs-link`,
'data-num': num,
href: '#' + (properties.id || ''),
};
const title = getCodeString(children || []);
result.push({ tagName: 'a', type, properties: props, children: [{ type: 'text', value: title || ' ' }] });
} else if (children?.length > 0) {