-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Collections with some custom extensions break. #776
Comments
@erquhart @Benaiah @verythorough Any thoughts? |
I think it makes sense that one should imply the other, since in the vast majority of cases, they will be the same. On the implementer side, I don't think it really matters which of the two is the "implied" field, so if "let |
Thoughts:
Thoughts? |
@erquhart that would prevent you from having a folder of data files with a custom extension - for instance, a folder of |
@erquhart I think that what you are discussing is slightly different than what I am in this issue. In this issue specifically, I'm just wondering whether we should try to infer the format of new entries when |
|
Still, I'm not talking about front-matter format, but the actual file format (JSON, YAML, MD, TOML). |
Yeah I was thinking frontmatter. So assuming the extension is something that makes sense, we always infer, but @Benaiah is right, we need to allow folks to trump all by setting both, and split between format and frontmatter format. |
Quoting @Benaiah from #797 (comment):
|
Status if we start inferring format from extension:
|
So we do indeed need to add a For some reason that table, although lovely, is hard for me to parse just looking at it, so let me know if we're on the same page - here's what I'd expect for file formats:
Anything missing here? |
Your list is what we are doing for writes, the order for reads is also an issue here:
Also, when reading, we filter out every file that does not match the extension that we are using (inferred or manually set). Agreed? |
The problem here is what to do if there are multiple extensions. If there are, there's no great way to pick. For example, we could go with whichever is most prevalent, but that balance can change, and suddenly the user sees a different set of files in the collection. We could also only infer from extension if all files have the same extension, but that means checking every file extension, which won't work when/if pagination is a factor. Can you see any other way? Otherwise I'm thinking the rules I wrote apply for both read and write, and we can still infer format from extension on read. |
Ahh, you are correct there, since we filter out everything that doesn't match the extension, and the extension is set by default to |
- Do you want to request a feature or report a bug?
bug, related to #763
- What is the current behavior?
If a custom file extension is set in the collection config, and it is one of the ones in
/src/formats/formats.js
:formatByExtension()
, the file will be saved as frontmatter. But the format of the file will try to be inferred when reading, so the file cannot be read.- If the current behavior is a bug, please provide the steps to reproduce.
extension: json
. Do not set aformat
.- What is the expected behavior?
The behavior should be consistent between reads and writes. If we try to infer the format while reading we should try to infer it while writing as well, or infer neither time.
Discussion Summary: #776 (comment)
- Please mention your CMS, node.js, and operating system version.
CMS 0.6.0
The text was updated successfully, but these errors were encountered: