0

I need to achieve this frontmatter:

    services:
      - service:
        serviceName: Service 1
        serviceDesc: Blah
      - service:
        serviceName: Service 2
        serviceDesc: Blah
      - service:
        serviceName: Service 3
        serviceDesc: Blah

Here is my current Yaml syntax:

    services:
      service:
        - serviceName: Water Treatment
          serviceDesc: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
            eiusmod tempor incididunt ut labore et dolore magna aliqua.
        - serviceName: Environmental Services
          serviceDesc: Lorem ipsum dolor sit amet, consectetur adipiscing eliy, sed do
            eiusmod tempor incididunt ut labore et dolore magna aliqua.

I am using Netlify CMS to create this but I cannot find a solution to get an individual service to use with Nunjucks.

Any help would be amazing.

kukihi
  • 23
  • 3

1 Answers1

0

Seeing your config.yml file would help, but from the look of your current output, I will assume that it looks something like this:

- label: 'Services'
  name: 'services'
  widget: 'object'
  fields:
    - label: 'Service'
      name: 'service'
      widget: 'list'
      fields:
        - { label: 'Name', name: 'serviceName', widget: string }
        - { label: 'Description', name: 'serviceDesc', widget: text }

In you case, you want the service node to be one level lower, wrapping each list element, so you should be able to just switch the position of your object and list widgets like so:

- label: 'Services'
  name: 'services'
  widget: 'list'
  fields:
    - label: 'Service'
      name: 'service'
      widget: 'object'
      fields:
        - { label: 'Name', name: 'serviceName', widget: string }
        - { label: 'Description', name: 'serviceDesc', widget: text }
qbeauperin
  • 591
  • 4
  • 21