Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix duplicate sidebar when include audio file #1521

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
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