-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Is your feature request related to a problem? Please describe.
I'm trying to find a way to get netlify-cms to understand French/English page pairs in different subfolders. I'm working with Hugo, and the way they handle translation of paths is to provide a translationKey frontmatter field that links two pages in differently named folders.
Given the following file structure:
src
├── content
│ ├── en
│ │ └── resources
│ │ └── index.md
│ └── fr
│ └── ressources
│ └── index.md
with frontmatter for the en one like:
---
title: Resources
slug: resources
date: 2020-10-30T14:33:09.744Z
translationKey: resources
---
vs the fr one:
---
title: Ressources
slug: ressources
date: 2020-10-30T14:33:09.744Z
translationKey: resources
---
and the following netlify-cms config.yml:
.
.
.
i18n:
structure: multiple_folders
locales: [en, fr]
collections:
- name: 'page'
label: 'page'
folder: '/src/content'
i18n: true
create: true
editor:
preview: true
nested:
depth: 100 # max depth to show in the collection tree
summary: '{{title}}' # optional summary for a tree node, defaults to the inferred title field
fields:
- { label: 'Title', name: 'title', i18n: true, widget: 'string' }
- { label: 'Path', name: 'slug', i18n: true, widget: 'string', required: false }
- { label: 'Meta description', name: 'description', required: false, i18n: true, widget: 'string' }
- { label: 'Publish Date', name: 'date', i18n: true, widget: 'datetime' }
- { label: 'Translation key', name: 'translationKey', required: false, i18n: true, widget: 'hidden', default: '{{slug}}' }
- { label: 'Body', name: 'body', i18n: true, widget: 'markdown' }
Netlify-cms sees them as unrelated pages:
and
Likewise when creating content. I fill out the English and French sides of the editor, adding different path values, and get pages with this kind of frontmatter:
src/content/en/covid-19.md
---
title: Covid-19
slug: covid
description: ""
date: 2020-11-27T14:44:25.843Z
translationKey: "{{slug}}"
---
and
src/content/en/covid-19.md
---
title: Covid-19
slug: covid
date: 2020-11-27T14:44:25.859Z
translationKey: "{{slug}}"
---
(not sure why description doesn't show up in the French file, but that's another issue).
The {{slug}}
part isn't being resolved as expected. I'd expect to see covid there.
Describe the solution you'd like
I'd like to see 2 things:
- The collections browser should use frontmatter like translationKey (for Hugo; not sure what equivalents are for other frameworks) to match translated files.
- The widgets like string and hidden should support parsing template tags like
{{slug}}
.