Posting here at the suggestion from the chat.
NetlifyCMS resolves regular filename collisions by appending a numeric index, e.g.
/entries/concert.md
/entries/concert-1.md # different concert, fine
/entries/concert-2.md # ditto
I'm using the folder collections path BETA feature like so: {{slug}}/index. The intent is to have a page bundle (as is common in some SSGs), i.e. one folder per page, usually with related page media inside.
The problem I noticed is that filename collisions get resolved as above (not surprising):
/soccer-tournament/index.md
/soccer-tournament/index-1.md
/soccer-tournament/index-2.md
/soccer-tournament/lineups.jpg
/soccer-tournament/tickets.json
Whereas the user would want collisions to be resolved at the folder/slug level:
/soccer-tournament/index.md
/soccer-tournament/lineups.jpg
/soccer-tournament/tickets.json
/soccer-tournament-1/index.md # different soccer tournament
/soccer-tournament-2/index.md # …
I hope that makes sense.
Hi, is this issue available?
@tiuweehan I've assigned you to the issue (assuming you meant available to work on - if not let me know).
A good place to start should be here:
https://github.com/netlify/netlify-cms/blob/908c42fb588ce87f4e197df65db2d238f34837f4/packages/netlify-cms-core/src/backend.ts#L243
Thanks for jumping in on this!
@tiuweehan I've assigned you to the issue (assuming you meant available to work on - if not let me know).
Yup, that's what I meant.
A good place to start should be here:
Great, that's helpful. Thanks!
Does someone work on that? If not, I would like to work on it.
Hi,
I have a question to understand the requirement clearly and be on the same page with you.
Our posts look like that:
/collections/posts/entries/2020-10-01-test
/collections/posts/entries/2020-10-01-test-1
When I debug the code, I saw we have a custom path and default path.
With this change, as I understood, when we give the same file name, we should show it in different folders.
Like this:
/collections/posts/entries/2020-10-01-test
/collections/posts/entries-1/2020-10-01-test
So if I want to use a custom path like that:
/collections/posts/nilay/2020-10-01-test
/collections/posts/nilay-2/2020-10-01-test
So I have to make changes for both default and custom path. Right?
@adrian5 @erezrokah
Hi Kacer,
I'm preoccupied with other things at the moment and haven't interacted directly with NetlifyCMS for a while now, so I'm afraid I can't give any valuable insight.
Assuming NetlifyCMS hasn't changed the default approach, the change should apply _only_ to those cases where the user specifies the path variable (for folder collections). Without that, the files are stored as usual (test, test-1, test-2, etc.)
I don't know what the "custom" path is, but anything that causes NetlifyCMS to switch to a _folder-per-page_ hierarchy should apply enumeration to those folders (upon name collision), as in my original example. Your two examples (entries, nilay) look correct to me.
@erezrokah works with the codebase, so hopefully he can answer your question.
Path handling in the CMS is quite complicated.
I would suggest that before making any code changes, we decide in which cases we should index the filename and in which cases we should index the directory name and how to infer those based on the configuration.
Custom path is quite new and related to the nested path feature allowing user to manually edit entry paths.
I did some tests to understand the requirement better.
I've changed the config file and add a path to try to custom path.
folderAtest.path : /collections/posts/entries/folderA/2020-10-09-testtestpath: /collections/posts/entries/folderA/2020-10-09-test-1folderBtestpath: /collections/posts/entries/folderB/2020-10-09-testAs far as I understand, we want to change the folder name if the user adds the same file name.
For instance; if we create same file name as atest file, the path will look like that:
/collections/posts/entries/folderA-1/2020-10-09-test
To change the pathname as folderA-1, we should index the folder name folderA and filename together.
If we make these changes for the custom path, the behavior will be inconsistent with the default case.
@erezrokah correct me if I am wrong but this change seems complicated and to be honest I am not sure we should add that feature as I didn't understand the benefit of that yet. WDYT?
Thank you for looking into this @KancerEzeroglu. I think there is no easy way to solve this use case without a more generic mechanism to control sluggification.
I think we can close this in favour of https://github.com/netlify/netlify-cms/issues/445, WDYT?
I agree, but I can't close :) fyi
Most helpful comment
Does someone work on that? If not, I would like to work on it.