FIX: Generate unique IDs for non-Latin languages (#36)

This commit is contained in:
Penar Musaraj 2022-05-05 14:25:37 -04:00 committed by GitHub
parent 26f4e45dc2
commit c658e95d54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View File

@ -32,10 +32,11 @@ export default {
return;
}
headings.forEach((h) => {
headings.forEach((h, index) => {
// suffix uses index for non-Latin languages
const suffix = slugify(h.textContent) || index;
const id =
h.getAttribute("id") ||
slugify(`toc-${h.nodeName}-${h.textContent}`);
h.getAttribute("id") || slugify(`toc-${h.nodeName}-${suffix}`);
h.setAttribute("id", id);
h.setAttribute("data-d-toc", id);

File diff suppressed because one or more lines are too long