@jamify-it/netlify-cms-widget-list-relation
v0.1.7
Published
Netlify CMS widget for adding relation to a list from a file in a collection
Downloads
7
Maintainers
Readme
@jamify-it/netlify-cms-widget-list-relation
This is a widget for Netlify CMS.
Standard relation widget only allows for using folder collection. This widget works with files collections instead, or to be more precise, with lists inside those files. See
Install
As an npm package:
npm install --save @jamify-it/netlify-cms-widget-list-relationimport ListRelation from '@jamify-it/netlify-cms-widget-list-relation';
CMS.registerWidget('list-relation', ListRelation.Control, ListRelation.Preview);How to use
Add to your Netlify CMS configuration:
fields:
- name: authors,
label: Authors,
widget: list-relation
collection:
name: settings # name of the collection
file: people # name of the file
field: authors # key of the field containing a list
# other settings as in the relation widget
multiple: true
searchFields: [name, email]
valueField: email
displayField: nameThis assumes you have a files collection named settings (see example below).
For info on fields multiple, searchFields, valueField and displayField, refer to relation widget documentation.
Example
File site/data/settings/people.yml:
authors:
- {name: Jane Jones, email: [email protected]}
- {name: Dan Doe, email: [email protected]}File site/content/projects/summer-project.md:
---
name: My Great Summer Project
authors: [[email protected], [email protected]]
---File config.yml (showing only collections):
collections:
- name: settings
label: Settings
files:
- name: people
label: People
file: site/data/settings/people.yml
extension: yml
fields:
- name: authors
label: Authors
widget: list
fields:
- {name: name, label: Full name, widget: string}
- {name: email, label: Email, widget: string}
- name: projects
label: Projects
folder: site/content/projects
fields:
- {name: name, label: Full name, widget: string}
- name: authors,
label: Authors,
widget: list-relation
collection:
name: settings
file: people
field: authors
multiple: true
searchFields: [name, email]
valueField: email
displayField: nameSupport
For help with this widget, open an issue or ask the Netlify CMS community in Gitter.
Attributions
- based on netlify-cms-widget-relation and heavily modified
- project setup from netlify-cms-widget-starter, but needed updating
