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

Nested Collections Listing #7384

Open
ryangittings opened this issue Jan 30, 2025 · 12 comments
Open

Nested Collections Listing #7384

ryangittings opened this issue Jan 30, 2025 · 12 comments
Assignees
Labels
area: nested-collections type: bug code to address defects in shipped code

Comments

@ryangittings
Copy link
Contributor

Having an issue since the 3.6.0 update - it's causing nested index.md files in the collection to appear in the sidebar, rather than the main pages listing - unlike 3.5.0. This is a massive regression in my opinion.

Image
@ryangittings ryangittings added the type: bug code to address defects in shipped code label Jan 30, 2025
@demshy
Copy link
Member

demshy commented Jan 30, 2025

Hi @ryangittings do you mind sharing your config for this collection (and maybe a screenshot of the file structure)?

@ryangittings
Copy link
Contributor Author

local_backend: true
backend:
  name: git-gateway
  branch: main
media_folder: 'src/uploads'
public_folder: '/uploads'
editor:
  preview: false

meta: &META
  label: 'Meta'
  name: 'meta'
  widget: 'object'
  collapsed: true
  fields:
    - { label: 'Title', name: 'title', widget: 'string', required: false }
    - { label: 'Description', name: 'desc', widget: 'string', required: false }

button: &BUTTON
  label: Button
  name: button
  widget: object
  fields:
    - label: Text
      name: text
      widget: string
    - label: Link
      name: link
      widget: string
      
theme: &THEME
  label: Theme
  name: theme
  widget: select
  options: ['gray-100', 'navy-400', 'turq-100', 'gray-100']
  required: false

navigation: &NAVIGATION
  label: 'Navigation'
  name: 'eleventyNavigation'
  widget: 'object'
  collapsed: true
  fields:
    - { label: 'Key', name: 'key', widget: 'string', required: false }
    - { label: "Parent", name: "parent", widget: "relation", required: false, collection: "pages", search_fields: ["title"], value_field: "title", display_fields: ["title"] }
    - { label: 'Excerpt', name: 'excerpt', widget: 'markdown', required: false }
    - { label: 'Order', name: 'order', widget: 'number', required: false }
    - { label: 'Icon', name: 'icon', widget: 'image', required: false }

blocks: &BLOCKS
  label: Blocks
  name: blocks
  widget: list
  types:
    - label: Hero
      name: hero
      widget: object
      fields:
        - { label: 'Title', name: 'title', widget: 'string' }
        - { label: 'Image', name: 'image', widget: 'image', required: false }
        - { label: 'Decorator', name: 'decorator', widget: 'string' }
        - { label: 'Content', name: 'content', widget: 'markdown', required: false }

collections:
  - label: 'Pages'
    name: 'pages'
    folder: 'src'
    identifier_field: 'title'
    create: true
    extension: 'md'
    filter: { field: 'layout', value: 'layouts/page.njk' }
    meta: { path: { widget: string, label: 'Path', index_file: 'index' } }
    nested:
      depth: 10
      summary: '{{title}}'
    fields:
      - { label: 'Layout', name: 'layout', widget: 'hidden', default: 'layouts/page.njk' }
      - { label: 'Title', name: 'title', widget: 'string' }
      - *BLOCKS
      - *NAVIGATION
      - *META
Image

@martinjagodic
Copy link
Member

@ryangittings, thanks for raising this, and sorry for your trouble. This was introduced in PR #7359, which solved issue #4972. Nested collections are used in many ways, and we didn't anticipate this would impact you so severely. We also introduced this because nested collections are still flagged as beta, indicating that breaking changes are possible.

We will find some time to put this feature under an opt-in flag.

@ryangittings
Copy link
Contributor Author

I just think it makes no sense from a visual point of view. To have one page in the pages list seems like a bug to me - if all the other pages are on the same level? The UI only ever shows one page in this setup - which fundamentally is incorrect with the tree.

@demshy
Copy link
Member

demshy commented Jan 31, 2025

@ryangittings would you mind testing with the following cms build (built from the linked PR) and config settings:
https://loquacious-bombolone-591afc.netlify.app/decap-cms.js

    nested:
      depth: 10
      subfolders: true
      summary: '{{title}}'

@ryangittings
Copy link
Contributor Author

@demshy this resolves the issue - yes!

@ryangittings
Copy link
Contributor Author

But - I'd prefer something that isn't a breaking change for all the sites I've built with Decap.

@ryangittings
Copy link
Contributor Author

Any update on this? It's a breaking change and I'm getting a lot of support enquiries asking why this has changed? Cheers!

@martinjagodic
Copy link
Member

@ryangittings, we are collecting feedback on this issue to see if anyone has a similar situation to you. For now, it looks like more users are in favor of subfolders: false being the default. We will merge this flag soon, but you will have to add it to all your projects.

@demshy can we make this flag available on the root level also?

@ryangittings
Copy link
Contributor Author

@martinjagodic I can't stress how important this is for me as a decision. As you've acknowledged, this is a breaking change (even if it's a minority use case), and as such should be an opt in, rather than opt out - as it's fundamentally broken to UX of all my CMS based sites. I have lost a bit of confidence in the CMS to be honest.

@demshy
Copy link
Member

demshy commented Feb 12, 2025

Here is my proposal (I have discussed it already with @martinjagodic):

I will make a patch (will probably release today) that will make the subfolders flag true. We then have until the next major release to decide which one we want as default.
At the next major, we can put nested collections out of beta and note the breaking change in case we decide that we want the new approach to be default.
So I'd suggest that you add the param to all the projects that you work on until then.

@demshy
Copy link
Member

demshy commented Feb 13, 2025

the patch has been released as 3.6.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: nested-collections type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

3 participants