Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/core/render/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export class Compiler {
this.router = router;
this.cacheTree = {};
this.toc = [];
this.uniqueTOC = [];
this.cacheTOC = {};
this.linkTarget = config.externalLinkTarget || '_blank';
this.linkRel =
Expand Down Expand Up @@ -235,7 +236,12 @@ export class Compiler {
const slug = slugify(config.id || str);
const url = router.toURL(router.getCurrentPath(), { id: slug });
nextToc.slug = url;
_self.toc.push(nextToc);

// FIXME: Maybe we can do the de-duplication directly from _self.toc
if (_self.uniqueTOC.indexOf(url) === -1) {
_self.uniqueTOC.push(url);
_self.toc.push(nextToc);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear what this changes or how the original problem happens. Can you explain?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You only pointed to some code. Can you explain?

media files should not have anything to do with the sidebar, so it seems this is not the correct fix, and that we should fix a problem with embedding media (or other stuff too maybe).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is, that fact that this code seems entirely unrelated to media files, yet fixes the problem, seems more like a workaround than an actual fix.

firstly, why does adding media files cause duplication?


return `<h${level} id="${slug}"><a href="${url}" data-id="${slug}" class="anchor"><span>${str}</span></a></h${level}>`;
};
Expand Down