@codedoc/core
Version:
Create beautiful modern documentation websites.
30 lines • 1.13 kB
JavaScript
export function guessTitle(content, base, connector = ' | ') {
for (let i = 0; i < content.children.length; i++) {
const target$ = content.children.item(i);
if (target$ instanceof HTMLHeadingElement) {
let text = '';
if (target$.childElementCount > 0) {
target$.childNodes.forEach(child => {
if (!(child instanceof HTMLElement && child.hasAttribute('data-ignore-text')))
text += child.textContent || '';
});
}
else
text = target$.textContent || '';
text = text.trim();
if (base) {
if (text.length > 0)
return base + connector + text;
else
return base;
}
else
return text;
}
if (!(target$ === null || target$ === void 0 ? void 0 : target$.textContent) || target$.textContent.trim().length === 0)
continue;
return base || '';
}
return base || '';
}
//# sourceMappingURL=guess-title.js.map