Home
Support Forums

Collection components? Avoiding bloat and copypasta in config.yml

Not sure if I’m overseeing something in the documentation, but it there a way to configure components or similar to be used in collections?

My use case:
I’m using React + TypeScript to create a Website, meaning here I can create a component, say a button, that always has two inputs: Title and URL.

If I want to add a button through the CMS though, I need to copy/paste the fields whereever I need it. If I add something to the button at a later stage, I’ll have to refactor the entire collection file and add that field everywhere.

Our site currently has 4 landing page types, so that’s quite a bit of refactoring and bloat…

You can switch to javascript (instead of a yaml config) with the manual initialization function:

https://www.netlifycms.org/docs/beta-features/#manual-initialization

Very interesting! I’m a bit wary of using beta features, but I’ll give it a shot.

Don’t worry, it’s only part of the beta section because the documentation hasn’t been updated in a while. (source: Docs: move relevant features from Beta section to permanent docs · Issue #4608 · netlify/netlify-cms · GitHub)