UNPKG

@codedoc/core

Version:

Create beautiful modern documentation websites.

20 lines 958 B
import { ContentNavStyle } from './style'; export function ContentNav(options, renderer) { const classes = this.theme.classes(ContentNavStyle); const links = []; options.content.querySelectorAll('h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]').forEach(h$ => { let text = h$.textContent; if (h$.childElementCount > 0) { text = ''; h$.childNodes.forEach(node => { if (!(node instanceof HTMLElement && node.hasAttribute('data-ignore-text'))) { text += node.textContent || ''; } }); } links.push(renderer.create("a", { href: `#${h$.getAttribute('id')}`, class: h$.tagName.toLowerCase(), "data-content-highlight": h$.getAttribute('id') }, text)); }); return renderer.create("div", { class: classes.contentnav, "data-no-search": true }, links); } export { ContentNavStyle } from './style'; //# sourceMappingURL=index.js.map