-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Closed
Labels
- P2: nice to haveNot breaking anything but nice to have (priority)Not breaking anything but nice to have (priority)feat: content collectionsRelated to the Content Collections feature (scope)Related to the Content Collections feature (scope)
Description
Astro Info
Astro v5.16.0
Vite v6.4.1
Node v23.8.0
System Windows (x64)
Package Manager npm
Output static
Adapter none
Integrations @astrojs/mdx (v4.3.12)
@astrojs/sitemap (v3.6.0)
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Description:
When there are duplicate slug properties across two or more MD files, the routes will get overwritten without warning or error and only a single route will be created.
The issue is in the glob() loader. When we are populating the store, we don't check if the id (here the custom slug) is already defined in the store before adding the entry. So the entry is simply overridden, and the last one being added wins. (Credit to @ArmandPhilippot for identifying the root cause)
if (store.has(id)) {
console.log("DUPLICATE!");
}
How to reproduce:
- Install the "blog" template with
npm create - Add duplicate slug property in two MD files. E.g.:
first-post.md:
---
slug: 'fp'
---
markdown-style-guide.md:
---
slug: 'fp'
---
- Go to /blog. The "First Post" disappeared from the list because it was overwritten.
What's the expected result?
An error or at least a warning that a route is being overwritten. Right now it happens silently.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-i1sleqxz?file=src%2Fcontent%2Fblog%2Fmarkdown-style-guide.md
Participation
- I am willing to submit a pull request for this issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
- P2: nice to haveNot breaking anything but nice to have (priority)Not breaking anything but nice to have (priority)feat: content collectionsRelated to the Content Collections feature (scope)Related to the Content Collections feature (scope)