Skip to content

[v3] Live reload only updates the first collection when a file belongs to multiple collections #2966

@maximepvrt

Description

@maximepvrt

Environment

Reproduction

Code Example

import { defineContentConfig, defineCollection, z } from '@nuxt/content'

export default defineContentConfig({
    collections: {
        content: defineCollection({
            type: 'page',
            source: '**',
            schema: z.object({
                name: z.string()
            })
        }),
        devenirBenevole: defineCollection({
            type: 'page',
            source: 'devenir-benevole/**/*.yml',
        }),
        blogEngagement: defineCollection({
            type: 'page',
            source: 'blog-engagement/*.md',
            schema: z.object({
                date: z.string()
            })
        }),
    }
})

Describe the bug

When modifying a file that belongs to multiple collections, only the first collection in defineContentConfig is updated during live reload. This creates issues when trying to manage a global navigation by combining multiple collections.

Expected Behavior

  1. All collections referencing the modified file should update during live reload.

Additional context

Proposal

A built-in function (e.g., useGlobalNavigation()) to return a global navigation combining all collections would be very helpful, eliminating the need for custom merging. A function like useGlobalNavigation() could return a unified structure of pages with essential metadata (title, path, etc.) from all collections:

const navigation = useGlobalNavigation()

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions