toc
This commit is contained in:
parent
6a45e2bf36
commit
2cf88dffde
11 changed files with 177 additions and 154 deletions
|
|
@ -97,8 +97,19 @@ function createToc(config) {
|
|||
}
|
||||
}
|
||||
|
||||
tocNewLi.innerHTML =
|
||||
'<a class="toc-link" href="#' + tocElement.id + '">' + tocElement.innerHTML + '</a>';
|
||||
const chapter = tocElement.closest('.chapter');
|
||||
const author = chapter?.querySelector('.nav-author')?.textContent || '';
|
||||
const chapterType = chapter?.dataset.chapter || '';
|
||||
tocNewLi.dataset.author = author;
|
||||
if (chapterType) tocNewLi.classList.add('toc-' + chapterType);
|
||||
const typeSymbols = { entretien: '@', portfolio: '+', essai: '*' };
|
||||
const symbol = typeSymbols[chapterType] || '';
|
||||
tocNewLi.innerHTML =
|
||||
'<a class="toc-link" href="#' + tocElement.id + '">' +
|
||||
(chapterType ? '<span class="toc-type" data-toc-chapter="' + chapterType + '">' + (symbol ? '<span class="toc-type-symbole_before">' + symbol + '</span>' : '') + '<span class="text">' + chapterType + ' </span>' + (symbol ? '<span class="toc-type-symbole_after">' + symbol + '</span>' : '') + '</span>' : '') +
|
||||
'<span class="toc-title">' + tocElement.innerHTML + '</span>' +
|
||||
(author ? '<span class="toc-author">' + author + '</span>' : '') +
|
||||
'</a>';
|
||||
|
||||
tocUl.appendChild(tocNewLi)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue