docs icon indicating copy to clipboard operation
docs copied to clipboard

Duplicated Menu Items when Running Docs Locally

Open jme783 opened this issue 9 years ago • 12 comments

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.

jme783 avatar Apr 25 '16 18:04 jme783

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).

monkbroc avatar Apr 27 '16 13:04 monkbroc

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?

jme783 avatar Apr 27 '16 16:04 jme783

There has been an issue opened in collections for more than a year with tons of comments. That repo looks unmaintained.

monkbroc avatar Apr 27 '16 16:04 monkbroc

Gotcha. 👎 for Metalsmith ugh.

jme783 avatar Apr 27 '16 16:04 jme783

Maybe the fork linked in this comment will help. I'll investigate later https://github.com/segmentio/metalsmith-collections/issues/27#issuecomment-200580629

monkbroc avatar Apr 28 '16 13:04 monkbroc

Cool! Let's try it

jme783 avatar Apr 28 '16 15:04 jme783

I'll actually give this a try -- I'm spinning up a new branch right now

jme783 avatar Apr 28 '16 15:04 jme783

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

jme783 avatar Apr 28 '16 16:04 jme783

Sad trombone :musical_note:

monkbroc avatar Apr 28 '16 16:04 monkbroc

I believe that this has been fixed. @rickkas7 can comment.

brandoaire avatar Aug 02 '18 20:08 brandoaire

Confirmed this is still an issue.

jme783 avatar Aug 06 '18 18:08 jme783

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...

monkbroc avatar Aug 06 '18 19:08 monkbroc