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

[Bug] Cannot list multi-part extension files #1462

Closed
Nic128 opened this issue Jun 24, 2018 · 2 comments · Fixed by #1478
Closed

[Bug] Cannot list multi-part extension files #1462

Nic128 opened this issue Jun 24, 2018 · 2 comments · Fixed by #1478

Comments

@Nic128
Copy link

Nic128 commented Jun 24, 2018

- Do you want to request a feature or report a bug?
Bug

- What is the current behavior?
You can't list files using a multi-part extension.

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

extension: 'en.md'
format: 'frontmatter'
  • Create a new post, the post will be created properly. {{slug}}.en.md
  • You can't see any file listed for editing, even if the files exist.
  • I see the list data from ajax calls, but the filtering in the cms code is filtering everything out.

- What is the expected behavior?
If just using md list the files correctly, en.md should list the same files.

I found out how to use multi-part extension from this thread. #1399

- Please mention your versions where applicable.

Netlify CMS version: 1.9.2
Browser version: Firefox 60

Node.JS version: 8.11.2
Operating System: OSX

- Please link or paste your config.yml below if applicable.
https://gitlab.com/Nic128/one-click-hugo-cms/blob/master/site/static/admin/config.yml

@Nic128
Copy link
Author

Nic128 commented Jun 29, 2018

I did some digging.

entriesByFolder(collection, extension) {
    return this.api.listFiles(collection.get("folder"))
    .then(files => files.filter(file => fileExtension(file.name) === extension))
    .then(this.fetchFiles);
  }

fileExtension(file.name) is made to only return md from the filename. Makes sense.

fileExtensionWithSeparator from the pathHelper.js file has a lot of usecases I wouldn't want to break.

My use case could be solved by doing something this.

entriesByFolder(collection, extension) {
    return this.api.listFiles(collection.get("folder"))
    .then(files => files.filter(file => file.name.endsWith(extension)))
    .then(this.fetchFiles);
  }

But all the other cases wouldn't work. Trailing slash, etc...

If the slug with language {{slug}}.{{language}} gets added as part of 2.0, this fix won't be necessary.

@tech4him1
Copy link
Contributor

@Nic128 That's exactly the right fix, it was added to GitHub in #1123, but didn't get ported over to GitLab. Feel free to make a PR for that if you're up for it.

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

Successfully merging a pull request may close this issue.

3 participants