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

feat(nested collections): allow non-index files #7359

Merged
merged 3 commits into from
Jan 17, 2025
Merged

Conversation

fgnass
Copy link
Contributor

@fgnass fgnass commented Dec 23, 2024

This PR is based on #6498 and resolves all outstanding merge conflicts. It recreates the necessary test snapshots and ensures the feature aligns with the latest codebase.

Summary

This commit fixes #4972 to allow nested folders with additional content beyond an index file.

Side effect: To keep the feature simple, this will now show index files as pages within a folder in NetlifyCMS. This enables creating additional files alongside the given index, but is a change in behavior from the current implementation.

Additionally, this PR:

Test Plan

  1. Run the test suite:
    npm test
    
  2. Verify that all tests, including the recreated snapshot for NestedCollection.spec.js, pass successfully.
  3. Manually test the behavior of nested folders with additional content to ensure it functions as expected.

Checklist

  • I have read the contribution guidelines.
  • Tests have been updated to reflect changes.
  • Changes have been manually verified.

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

my-cat

This commit fixes decaporg#4972 to allow nested folders with additional content
beyond an index file.

Side effect: To keep the feature simple, this will now show index files
as pages within a folder in NetlifyCMS. This enables creating additional
files alongside the given index, but is a change in behavior from the
current implementation.

Co-authored-by: Eric Gade <[email protected]>
@fgnass fgnass requested a review from a team as a code owner December 23, 2024 12:59
 We use regexps as otherwise .contains("Sub Directory") would also match "Another Sub Directory"
@demshy
Copy link
Member

demshy commented Jan 17, 2025

Amazing work once again @fgnass .

I discussed and tested this with @martinjagodic against some of our projects that use this. I don’t think the breaking change dramatically changes the behaviour for current implementations, especially since the whole feature is still marked as Beta.

I suggest release this and discuss some kind of a temporary legacy mode in case of some reasonable concerns arise from the community.

We did encounter a semi-related issue though. When getNodeTitle obtains the title it will take the title of the first child, which is the _index file unless in this edge case there is a file name that starts with a number. In this case this will be the title of the section. We will investigate this a bit and open an issue that will address this and maybe even add a possibility to take the dir name as nodeTitle when _index file is not present.

@demshy demshy merged commit 47a2f70 into decaporg:main Jan 17, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make nested collections work with a flat content structure
4 participants