commercetools / commercetools-docs-kit

Tools and components for developing Documentation websites 🛠
https://docs-kit.commercetools.vercel.app
MIT License
18 stars 5 forks source link

Configurable Top Menu and Footer content (for migration) #396

Closed nkuehn closed 4 years ago

nkuehn commented 4 years ago

As already discussed at the beginning of the kit implementation, we are now nearing go live and it turns out we need to be able to configure the top nav and footer links - or at least toggle between "current" and "next" in the site options.

Reasons:

We did discuss live download from a central location, that's an option but i would already be very happy with being able to pull the data from a file or a file in another package.

emmenko commented 4 years ago

Should I look into this?

nkuehn commented 4 years ago

@davifantasia result from a quick call with Nicola: We'll try to use gatsby's code shadowing to simply override the files locally using gatsby component shadowing.

It means duplicating them for the 6 sites but that's good enough for the migration phase.

nkuehn commented 4 years ago

@emmenko FYI my research status:

So we'll have to do something in the actual theme, the simplest form would be to pass an option that allows to disable the theme's 'internalConfigurationData' loading.

emmenko commented 4 years ago

Have you tried simply creating a top-menu.yaml in src/data?

The yaml transformer should be able to pick it up and assign it to the TopMenu schema.

nkuehn commented 4 years ago

Yes, that's what I did. But as said in the above comment, the YAML plugin adds the menu entries to the existing menu entries, it does not replace them.

That's because the YAML source plugin is hardwired to require an array as the top level stucture of the yaml files whose entries are then automatically becoming nodes in a GraphQL type of the file name. If if finds two same named files it seems to just add the entries.

So to really override you have to stop the theme from providing its own files.

nkuehn commented 4 years ago

PS: if you mean "just" putting it into the website folder? That leads to nothing, the loader is explicitly configured to look into __dirname, that was the whole point of it originally

emmenko commented 4 years ago

No the source plugin is configured to load data folders both in the theme and in the website. Yes, it adds the new entries to the existing one. I thought this was enough, or do you want to replace some of the menu items?

One option could be to allow a custom-top-menu.yaml in the website src/data, and instruct the theme to render that, if available. We could probably do that in gatsby-node.js when constructing their related nodes.

nkuehn commented 4 years ago

OK, back to zero and do not take 500 $. The use case:

emmenko commented 4 years ago

I have an idea, let me try something