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

Support extensions with multiple parts (i.e. en.md) #1123

Merged
merged 3 commits into from
Feb 27, 2018
Merged

Conversation

tech4him1
Copy link
Contributor

@tech4him1 tech4him1 commented Feb 20, 2018

- Summary

Fixes #877. See discussion there for context.

- Test plan

Manually tested. Is it worth mocking the API for listFiles to test this?

- Description for the changelog

Support extensions with multiple parts (i.e. en.md).
Clean leading periods from extensions.

- A picture of a cute animal (not mandatory but encouraged)

@verythorough
Copy link
Contributor

verythorough commented Feb 20, 2018

Deploy preview for netlify-cms-www ready!

Built with commit e2729eb

https://deploy-preview-1123--netlify-cms-www.netlify.com

@verythorough
Copy link
Contributor

verythorough commented Feb 20, 2018

Deploy preview for cms-demo ready!

Built with commit e2729eb

https://deploy-preview-1123--cms-demo.netlify.com

@tech4him1 tech4him1 changed the title WIP: Support extensions with multiple parts (i.e. en.md) Support extensions with multiple parts (i.e. en.md) Feb 20, 2018
@tech4him1
Copy link
Contributor Author

@talves @erquhart @Benaiah The user will still be required to manually specify a format here, do you think that's necessary, or should we grab the last part of the extension, and use that to infer the format?

@Benaiah
Copy link
Contributor

Benaiah commented Feb 20, 2018

@tech4him1 let's do the minimal change to fix #877 now and handle inference in a new issue/PR. I'm cloning this to test now.

@talves
Copy link
Collaborator

talves commented Feb 20, 2018

I agree with @Benaiah to get this moving forward, since it is a working incremental

@tech4him1 tech4him1 changed the title Support extensions with multiple parts (i.e. en.md) WIP:Support extensions with multiple parts (i.e. en.md) Feb 20, 2018
@tech4him1
Copy link
Contributor Author

tech4him1 commented Feb 20, 2018

There seems to be a bug when using the GitHub backend -- if you use html.md as the extension, html turns into part of the slug instead of the extension.

Affecting code:
https://github.com/netlify/netlify-cms/blob/afce6abbc28e31b986a8f2d670dd4f6fe35c1316/src/reducers/collections.js#L60

@tech4him1 tech4him1 changed the title WIP:Support extensions with multiple parts (i.e. en.md) Support extensions with multiple parts (i.e. en.md) Feb 21, 2018
@tech4him1
Copy link
Contributor Author

@Benaiah @talves Pushing a fix now.

@erquhart
Copy link
Contributor

erquhart commented Feb 23, 2018

@tech4him1 I tested this locally and it works great 🍻

I do think one bit of sanitization is in order, though - when trying this, I assumed the extension should include a dot, so I set .en.md in the config, which led to my-file..en.md. Which actually didn't break anything, but we should at least strip any dots from the beginning of the user-supplied extension, as others will surely run into it.

Once that's fixed, LGTM.

@ryantownsend
Copy link

Also validated this myself, including deploying to Netlify itself. Would be great to see this merged.

@tech4him1 tech4him1 self-assigned this Feb 27, 2018
@tech4him1
Copy link
Contributor Author

tech4him1 commented Feb 27, 2018

@erquhart Updated to clean leading periods from extensions.

@erquhart erquhart merged commit c765cb0 into master Feb 27, 2018
@erquhart erquhart deleted the multi-extension branch February 27, 2018 22:24
tech4him1 added a commit to tech4him1/netlify-cms that referenced this pull request Jul 30, 2018
Since we are building the regex with `new RegExp`, the escapes must be
double-escaped. Instead of `\.` to esape the period, we need `\\.`.
Because that was not done, we were simply checking for *any* character,
instead of a literal period.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Entries with complex extensions do not appear in collection view
6 participants