docs
docs copied to clipboard
Duplicated Menu Items when Running Docs Locally
Live reload is causing a full rebuild of Metalsmith, and the sidebar menu navigation. This causes duplicate page headers during development, and the links often times do not correctly link to the proper pages.
We should figure out a way to trigger the metalsmith rebuild to be more specific and targeted, and not trigger a full rebuild.
tl;dr this isn't something I managed to fix quickly so I'll punt it until later :(
This is due to the interaction between metalsmith-watch and metalsmith-collections.
The run operation in metalsmith-collections is not idempotent so running it multiple times corrupts the collections metadata in metalsmith.metadata(). The collections are stored both directly in metadata and in metadata.collections.
When metalsmith-watch sees a file change, it triggers a metalsmith.run for that file. In turn this runs metalsmith-collections.run() only for that file and it adds a duplicate section.
In addition, metalsmith-watch has a LOT of code specifically to deal with the limitations in metalsmith-collections. It backs up the collections, then tries to restore them after the metalsmith.run(). It must have worked at some point in the past, but currently the hacks don't match the metadata layout metalsmith-collections so it just ends up making things worse (links don't link to proper pages).
Gotcha, thanks for looking into this @monkbroc. Is there any way we could create an issue somewhere on the metalsmith-watch or metalsmith-collections repos to raise visibility on this and get the maintainers of those libraries working on a fix?
There has been an issue opened in collections for more than a year with tons of comments. That repo looks unmaintained.
Gotcha. 👎 for Metalsmith ugh.
Maybe the fork linked in this comment will help. I'll investigate later https://github.com/segmentio/metalsmith-collections/issues/27#issuecomment-200580629
Cool! Let's try it
I'll actually give this a try -- I'm spinning up a new branch right now
Argh...wasn't able to figure out how to get this to work because we already forked and changed the metalsmith-collections repo: https://github.com/spark/metalsmith-collections#dynamic-collections
I don't want to suck too much time into this, so I'm gonna move on for now. Let me know if you take a stab
Sad trombone :musical_note:
I believe that this has been fixed. @rickkas7 can comment.
Confirmed this is still an issue.
Please don't spend time on this issue. I know it's annoying but it's internal-facing only so it's not the best use of your time. One day the tech stack will change and this issue will be closed...