The Wayback Machine - https://web.archive.org/web/20220627175318/https://github.com/netlify/netlify-cms/discussions/5917
Skip to content

Component Partials #5917

doostinharrell started this conversation in Ideas
Component Partials #5917
Oct 21, 2021 · 2 comments · 1 reply

I've been using Netlify CMS to build page layouts for a client recently and I really am enjoying how simple and powerful this basic CMS is. However, as I've been building complicated collections I have ran into a few limitations where I think things could be improved.

I have several collections that have common components (ie: a landing page has a gallery and so does a service page for example). It would be awesome if we could load in yml partials rather than duplicating common configuration.

Here is an example of what I'm thinking...

Possible Folder Structure:
config.yml -- /components/heading.yml -- /components/gallery.yml

Possible Yaml Structure:

collections:
  - name: landing_page
    label: Landing Page(s)
    identifier_field: label
    folder: "content/landing-pages"
    create: true
    editor:
      preview: false
    fields:
      - label: Components
          label_singular: component
          name: components
          widget: list
          types:
            - label: Heading
               name: heading
               config: 
                 import: components/heading.yml
            - label: Gallery
               name: gallery
               config:
                 import: components/gallery.yml

Replies

2 comments
·
1 reply

I understand the frustration here. I would end up voting against this idea to keep things simple in the parsing of the YAML config. But I'm not going to leave you hanging here.

Option 1: When I have a project with a large config with duplicated information, I use the "manual config" and build my config object using the JSON objects instead where I can import in common objects.

Option2: If the manual configuration and javascript setup doesn't fit your SSG page load scenario, you can always build the JSON config files and write a script to convert the JSON object to a YAML (config.yml) using a pre-publish script. This is something a developer could do using your suggested config above also.

The push back would be to keep the config processing simple in core netlify-cms and resist complicating a yaml config.

Look forward to hearing other opinions that might change my view.

1 reply
@doostinharrell

Thanks @talves. I had thought about Option 2 but for some reason manual config didn't cross my mind, so thanks for that. I'll review the manual config documentation and perform some additional testing around that setup.

Cheers!

Thanks @talves, that's great input. Linking #1342 for context as this was discussed in that issue as well.

0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
3 participants