Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field parameter to support adding quotes around field data #3505

Open
jeremyzilar opened this issue Mar 30, 2020 · 7 comments
Open

Field parameter to support adding quotes around field data #3505

jeremyzilar opened this issue Mar 30, 2020 · 7 comments

Comments

@jeremyzilar
Copy link
Contributor

Slightly related to #3486

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

Background: I oversee 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 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

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 🌈✨

@BasJan81
Copy link

I think quotes: true is a briljant idea.

Decisions, not Options

Every time you give a user an option, you are asking them to make a decision. When a user doesn’t care or understand the option this ultimately leads to frustration. As developers we sometimes feel that providing options for everything is a good thing, you can never have too many choices, right? Ultimately these choices end up being technical ones, choices that the average end user has no interest in. It’s our duty as developers to make smart design decisions and avoid putting the weight of technical choices on our end users.

  • WordPress Philosophy. 🤫

@dickreckard
Copy link

dickreckard commented Dec 7, 2021

Yes, +1 for quotes: true option..
Currently having an issue with a jekyll static site, where the liquid template interprets a field written as 12:12 as hours:minutes and mis-processes it.
Of course it is not a netlify-cms issue, it is a Jekyll front-matter issue, implicitly interpreting a field without giving handles to modify that behaviour, but I imagine similar situations can appear in other YAML processes, and the quoting options seems a super-useful addition for helping with that.

@manuelernestog
Copy link

I'm having the same issue with Astro an YAML processes with time fields :/

@pensivedog
Copy link

+1 for quotes: true option.

@martinjagodic
Copy link
Member

Since this seems to be a popular demand, I'm reopening the issue. Contributions welcome

@DannieBGoode
Copy link

same issue with Astro when since:

  • Decap CMS writes them like this: publishDate: 2023-09-08T15:55:00.972Z
  • but Astro expects them like this: publishDate: "2023-09-08T15:55:00.972Z"

kyoshino added a commit to sveltia/sveltia-cms that referenced this issue Sep 8, 2023
@egxdigital
Copy link

egxdigital commented Apr 30, 2024

same issue with Astro when since:

  • Decap CMS writes them like this: publishDate: 2023-09-08T15:55:00.972Z
  • but Astro expects them like this: publishDate: "2023-09-08T15:55:00.972Z"

same issue with Next.js.

I also want to wrap Image fields in quote strings because they are saved as URIs for the Next.js build step to find them.

I have attempted several workarounds, none of which have worked:

  • using the format parameter to explicitly specify IS08601 date strings
  • modifying my procedure for loading markdown and its frontmatter to 'stringify' the date and image URL property
  • replacing git-gateway with 'github' in the backend settings inside DecapCMS' config.yml (this creates another issue entirely)

Really wish there was a quotes: true for ALL DecapCMS fields

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants