decaporg / decap-cms

A Git-based CMS for Static Site Generators
https://decapcms.org
MIT License
17.93k stars 3.04k forks source link

`folder` collection of JSON data files saves files in markdown format #748

Closed verythorough closed 6 years ago

verythorough commented 7 years ago

- Do you want to request a feature or report a bug? bug, unless I've missed a setting

- What is the current behavior? Folder collections save files in markdown (with yaml frontmatter) by default. You can change the file extension by adding the extension field to the collection config. This causes files in the folder to be saved with the chosen extension, but the file contents are still in markdown with yaml frontmatter.

- If the current behavior is a bug, please provide the steps to reproduce.

  1. Log in at https://postman-toad.netlify.com/admin/ (Registration is open, and you can use your GitHub account.)
  2. Add a new JPost.
  3. Check your new file in the repo, and see that it is a JSON file, with yaml frontmatter contents. (I removed the body field from the config, thinking that it might be triggering the markdown format. You can see my first test, with body field intact, here.)

- What is the expected behavior? The contents of the file should match the extension.

- Please mention your CMS, node.js, and operating system version. 0.5.0 in a one-click-hugo-cms deploy, running on current Chrome

tech4him1 commented 7 years ago

Normally you should be able to do extension: json and format: json to get it to work. This is broken for JSON specifically, and should be fixed.

It does bring up an interesting issue, though: Instead of failing on an unsupported format, we just assume that it should be a markdown post. What do you think of just issuing a config error on an unsupported format, as an "Invalid Config" error. Or we could do it more gently, and just break that collection instead of the entire CMS? @erquhart @Benaiah?

verythorough commented 7 years ago

Interesting about having separate extension and format fields. I started thinking about cases where you'd have different values for each, and realized it might be a handy way to specify different frontmatter formats. (We can read yaml/toml/json frontmatter, but only write yaml.) For example, extension: md and format: toml would make a markdown file with toml frontmatter. Might be overgeneralizing, though, leading to more confusion than it's worth.