decaporg / decaporg/decap-cms

Field parameter to support adding quotes around field data

Open
#3,505 7 comments 4 reactions 0 assignees View on GitHub
area: configuration area: extensions/widgets pinned
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

Slightly related to https://github.com/netlify/netlify-cms/issues/3486

### Is your feature request related to a problem? Please describe.

**Background:** I oversee [Digital.gov](https://digital.gov/), a site provides guidance around making better digital services for people in government. All of our websites are built using static site generators (Jekyll, Hugo), and use a mix of [Federalist](https://federalist.18f.gov/) and GitHub to publish the pages.

Currently, most of the edits to our sites are made directly in the GitHub website from people not in our org, but people from around the government.

To make the process of editing fields easier, we are specifying that certain fields always have double quotes wrapped around them, regardless if there is a need for them or not.

For example, in the YML spec, the title field in the example below would not require it to be wrapped in quotes (`title: "Introduction to Accessibility"`), but because we have many editors and content designers going in to update the text fields, having double quotes around certain fields helps to ensure that the text they add will not break the build. This can be adding a colon, apostrophe, markdown formatting, etc... (`title: "NEW: Introduction to Accessibility"`). We have found that asking editors to remember to add quotes around an item if it has special chars is not something we coach them on in the workflow.

Here is an example of data fields and text fields 👀
```
slug: introduction-accessibility
date: 2019-12-04 8:00:00 -0500
title: "Introduction to Accessibility"
deck: ""
summary: "An introduction to accessibility, and why it matters."
```
_[Here's the full file](https://github.com/GSA/digitalgov.gov/blob/master/content/resources/intro-accessibility.md)_

**Describe the solution you'd like**
We are now making a switch to use Netlify CMS, and we'd like to be able to keep the ability to specify if a field should be automatically wrapped in double-quotes. This could be done by adding an optional parameter to the field you'd want wrapped in quotes (e.g. `quotes: true`)

**Example:**
```
- label: "Agency Acronym"
name: "agency"
widget: "string"
hint: "e.g. GSA"
quotes: true
required: false
```

When it renders, the field would get wrapped in quotes automatically. Ideally, the field in Netlify CMS would also look for the insertion of double quotes in the field and escape them.

```
title: "The \"Best\" Introduction to Accessibility"
```

Thank you for considering this 🌈✨

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.