Skip to content

CollectionEntry.id is not invariant (it returns slug from frontmatter if slug field is defined) #16695

@EldarAgalarov

Description

@EldarAgalarov

Astro Info

Astro                    v6.3.1
Vite                     v7.3.2
Node                     v24.13.1
System                   Linux (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/mdx (v5.0.4)
                         @astrojs/sitemap (v3.7.2)

Describe the Bug

When frontmatter have slug field then CollectionEntry.Id returns slug value. This can break code that relies on CollectionEntry.Id parsing.

Workaround. Set custom generateId:
generateId: ({ entry }) => entry.replace(/\.mdx?$/, "")

The doc says nothing about such behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P3: minor bugAn edge case that only affects very specific usage (priority)fix pending verificationReporter needs to verify the triage bot fix workspkg: astroRelated to the core `astro` package (scope)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions