1
0
mirror of synced 2026-05-22 18:33:15 +00:00

DEV: Remove more code?

This commit is contained in:
Jarek Radosz
2022-10-02 19:14:23 +02:00
parent 09134b9093
commit 61b867aa34
@@ -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"];