DEV: Remove more code?

This commit is contained in:
Jarek Radosz 2022-10-02 19:14:23 +02:00
parent 09134b9093
commit 61b867aa34
No known key found for this signature in database
GPG Key ID: 62D0FBAE5BF9B953
1 changed files with 5 additions and 17 deletions

View File

@ -60,7 +60,7 @@ export default {
const topicCategory = post.topic.category_id;
const topicTags = post.topic.tags;
const hasTOCmarkup = el?.querySelector(`[data-theme-toc="true"]`);
const hasTOCmarkup = el.querySelector(`[data-theme-toc="true"]`);
const tocCategory = autoTocCategoryIds?.includes(topicCategory);
const tocTag = topicTags?.some((tag) => autoTocTags?.includes(tag));
@ -90,14 +90,16 @@ export default {
el.classList.add("d-toc-cooked");
if (document.querySelector(".d-toc-wrapper")) {
this.insertTOC(headings);
this.buildTOC(Array.from(headings));
document.addEventListener("click", this.clickTOC, false);
} else {
// try again if decoration happens while outlet is not rendered
// this is due to core resetting `canRender` for topic-navigation
// when transitioning between topics
later(() => {
if (document.querySelector(".d-toc-wrapper")) {
this.insertTOC(headings);
this.buildTOC(Array.from(headings));
document.addEventListener("click", this.clickTOC, false);
}
}, 300);
}
@ -147,20 +149,6 @@ export default {
}
},
insertTOC(headings) {
const dToc = document.querySelector(".d-toc-main");
const existing = document.querySelector(".d-toc-wrapper .d-toc-main");
if (existing) {
document.querySelector(".d-toc-wrapper").replaceChild(dToc, existing);
} else {
document.querySelector(".d-toc-wrapper").appendChild(dToc);
}
this.buildTOC(Array.from(headings));
document.addEventListener("click", this.clickTOC, false);
},
clickTOC(e) {
const classNames = ["d-toc-timeline-visible", "archetype-docs-topic"];