starlight-blog
starlight-blog copied to clipboard
"Missing date" error when using a custom prefix
Describe the bug
When using starlight-blog with a custom prefix to apply its features to an existing content directory (e.g., /tech), the plugin throws a Missing date for blog entry '...' error. This error occurs even though a date field with the format YYYY-MM-DD is correctly defined in the frontmatter of the articles, as shown in the documentation.
To Reproduce
Steps to reproduce the behavior:
- Setup Project: Set up a standard Astro Starlight project. Place content files in a subdirectory, for example:
src/content/docs/tech/. - Install Plugin: Install
starlight-blogusingnpm i starlight-blog. - Configure Plugin: In
astro.config.mjs, importstarlight-blogand add it to the Starlight plugins array with a customprefix.starlightBlog({ prefix: 'tech', }) - Configure Schema: In
src/content/config.ts, extend thedocsSchemawith theblogSchema.export const collections = { docs: defineCollection({ schema: docsSchema({ extend: (context) => blogSchema(context) }) }), }; - Create Content: Ensure an article in
src/content/docs/tech/has adatefield in its frontmatter.--- title: My Article date: 2024-09-22 --- - Run Server: Run the development server with
npm run dev. - See Error: Observe the
Missing date for blog entry...error in the console.
Expected behavior
The plugin should correctly identify the date field from the article's frontmatter. The page should render without errors, and the starlight-blog features (such as tags on the page and the sidebar widgets) should be applied to the articles under the /tech route.
How often does this bug happen?
Every time
System Info
- Astro:
^5.13.7 - @astrojs/starlight:
^0.35.3 - starlight-blog: (latest version)
Additional Context
No response
Thanks for the report 🙌
I'm not able to reproduce such issue. Here is a StackBlitz example using your configuration and content which works as expected.
Would you be able to provide a reproduction or a link to the repo where you're hitting this issue?
Thanks for your reply! I think this is probably an issue specific to my environment, so at some point I’d like you to take a look at my repo. Right now it contains a lot of personal information, so I’ll need to prepare it first.
Anyway, even though I’ve written the date, I keep getting the message “Missing date for blog entry...” endlessly.
In particular, I really want to use the tags feature. Being able to list up articles with specific tags would be great. Honestly, I’d love to see this functionality officially added to Starlight itself.