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
index.md doesn't get loaded when using <ContentDoc> with dynamic routing. #1189
Comments
I think we shall for the path to be equal and not starting by when using ContentDoc @farnabaz |
the same questions |
The issue appears to be caused by this PR: #1143 |
@Atinux From some rough experimenting, updating https://github.com/nuxt/content/blob/main/src/runtime/composables/query.ts#L44 export function queryContent<T = ParsedContent> (query?: string | QueryBuilderParams, ...pathParts: string[]) {
if (typeof query === 'string') {
let path = withLeadingSlash(withoutTrailingSlash(joinURL(query, ...pathParts)))
// escape regex special chars
- path = path.replace(/[-[\]{}()*+.,^$\s]/g, '\\$&')
+ path = path.replace(/[-[\]{}()*+.,^$\s/]/g, '\\$&')
- return createQuery<T>(queryFetch).where({ _path: new RegExp(`^${path}`) })
+ return createQuery<T>(queryFetch).where({ _path: new RegExp(`^${path}$`) })
}
return createQuery<T>(queryFetch, query)
} to include |
Environment
Reproduction
I reproduced the issue in stackblitz.
https://stackblitz.com/edit/nuxt-starter-jx8vzt
Describe the bug
When using dynamic routing, rather than loading the
index.md
file inside the directory pointed to by$route.path
, the page loaded is the first one found alphabetically inside the directory pointed to by$route.path
.Additional context
As far as I know, this bug isn't in 2.0.0.
Logs
No response
The text was updated successfully, but these errors were encountered: