Netlify-cms: When loading collection entries, ignore non-markdown files

Created on 14 Mar 2017  路  6Comments  路  Source: netlify/netlify-cms

Currently every file in a folder based collection is expected to be an entry - even having a .keep file will break the app. Instead, the CMS should simply ignore files that are not markdown.

Requirements

  • Check the extensions of entries when loading files for a folder based collection
  • If the file extension is md, process as usual
  • If the file extension is not md, ignore it

Considerations

  • Some markdown files may also need to be ignored, as mentioned in #218
  • In lieu of formally accepting a list of files to ignore in the config, we could adopt the convention of ignoring markdown files prefixed with an underscore
good first issue

Most helpful comment

@erquhart one option then is we could allow an array of extensions for a collection (as well as a string if just a single value) - with the default changing from 'md' to ['md', 'markdown']. The first extension would be used when creating files, when listing files it match against any extension in the array; how does that sound?

All 6 comments

We wouldn't to just ignore all markdown files that start with an underscore, because some CMS's such as Hugo use them (for example content\_index.md).

@tech4him1 thanks for that - somehow I wasn't considering that you'd want to edit the index file in the CMS 馃檮

So the files view of the collection should only show files matching the extension defined in the collection or .md if none is defined?

What about .markdown files if I have the extension set to .md - is that something we should handle, or leave for now (also affects https://github.com/netlify/netlify-cms/issues/317)?

@josephearl we can keep the two issues separate, but fixing both in one shot definitely works too.

@erquhart one option then is we could allow an array of extensions for a collection (as well as a string if just a single value) - with the default changing from 'md' to ['md', 'markdown']. The first extension would be used when creating files, when listing files it match against any extension in the array; how does that sound?

@josephearl that works!

Was this page helpful?
0 / 5 - 0 ratings