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

Remove leading/trailing whitespace in frontmatter when submitting #7398

Open
CharlyMartin opened this issue Feb 10, 2025 · 0 comments
Open
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality

Comments

@CharlyMartin
Copy link

CharlyMartin commented Feb 10, 2025

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

I’m a developer at Filecoin Foundation and review content PRs coming from Decap CMS.

I’ve noticed that some Markdown entries have leading and trailing spaces in the frontmatter. I don't think our content team does this intentionally, but either way, there should be a way to automatically clean the frontmatter strings before submission to GitHub. The result would be the equivalent of calling .trim() on the strings.

---
title: " Fresh From FF: February, 2025 " # Should not happen
created-on: 2025-02-03T15:32:00.000Z
updated-on: 2025-02-03T15:32:00.000Z
published-on: 2025-02-03T15:32:00.000Z
category: reports
description: Check out the latest updates about what Filecoin Foundation has been up to.

Describe the solution you'd like

I believe this should be handled automatically. I can’t think of a scenario where leading or trailing spaces in a string are intentional or useful for content authors.

If doing it automatically isn’t an option, there should at least be a option in config.yml, such as:

local_backend: true
site_url: https://fil.org
display_url: https://fil.org

# ...

trim_whitespace: true

Describe alternatives you've considered

We tried registering a pre-save hook to do this, but handling all edge cases—especially with deeply nested content—proved to be too tricky.

We also tried using Prettier to clean the content, but it doesn’t remove whitespace from strings enclosed in quotation marks.

Additional context

Let me know if I can help!

Thank you 🙂

@CharlyMartin CharlyMartin added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

No branches or pull requests

1 participant