getkirby / eleventylab

Experimental 11ty setup that reads from Kirby's content folder
11 stars 2 forks source link

Frontmatter camelcase entry #2

Open stebrech opened 1 year ago

stebrech commented 1 year ago

I use eleventyNavigation on some pages which has indented key and order. Kirby overwrites the camelcase written eleventyNavigation and adds a pipe.

Before saving:

eleventyNavigation: 
  key: some key
  order: 3

After saving the page in Kirby:

eleventynavigation: |
  key: some key
  order: 3

Although I currently have this added manually to the markdown files and not integrated into the Kirby Config, CamelCase written objects do not seem to be accepted. I wouldn't know how to manage this indentation either.

stebrech commented 1 year ago

With the structure field type it can be configured in Kirby, but still the issue with camelcase and the pipe. Additionally it adds a hyphen:

    fields:
      eleventyNavigation:
        label: Link in Hauptmenü
        type: structure
        fields:
          key:
            label: Linktext
            type: text
          order:
            label: Nr. Reihenfolge
            type: number

Result:

eleventynavigation: |
  -
  key: some key
  order: 9
lukasbestle commented 1 year ago

The frontmatter fields are mapped to Kirby fields internally. Kirby treats field names as case-insensitive, which is why the name gets changed to lowercase. Kirby fields are also always strings, so the nested YAML structure gets parsed as a string and converted back to an indented YAML string instead of the actual dictionary structure that was there before.