docs(cookbook): add blog index recipe (v2)#8679
Conversation
v2 sister PR to QwikDev#8671 (which targets main/v1), requested by maiieul so the recipe lands on build/v2 without cross-branch merge conflicts. A compiled MDX/MD file's `default` export is a Qwik component, and the Glob Import recipe warns against `eager: true` for Qwik components. This v2 version drops eager: it scopes the glob to the `frontmatter` export (`import: 'frontmatter'`) so the component is never pulled in, and resolves the lazy entries server-side in a routeLoader$. - packages/docs/src/routes/docs/cookbook/blog-index/index.mdx — the recipe - packages/docs/src/routes/demo/cookbook/blog-index/ — runnable demo (index.tsx + 3 posts) - packages/docs/src/routes/docs/cookbook/index.mdx — overview entry (alphabetized) - packages/docs/src/routes/docs/menu.md — sidebar entry Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
|
@youcefzemmar did you manually check that this work yourself? Claude says it couldn't run a normal preview. You should be able to test that in a blank starter app. |
|
Yes — I manually verified it this time in a blank v2 starter as you suggested (npm create qwik@beta, @qwik.dev/core + @qwik.dev/router 2.0.0-beta.35), dropping the recipe in verbatim under /blog:
So the recipe works end to end on v2. The earlier "couldn't run a preview" note was just my local env missing the Rust optimizer for a full monorepo build — the recipe itself renders fine in a normal starter |
What
v2 sister PR to #8671 (which targets
main/v1). Adds the Blog Index cookbook recipe — building a listing page from MDX/MD files usingimport.meta.glob+ Qwik Router'sfrontmatterexport — plus a runnable demo at/demo/cookbook/blog-index/with three sample posts (two.mdx, one.md).Opened separately on
build/v2at @maiieul's request on #8671 — the v1 PR can't be merged across because of conflicts.Fixes #3796.
What changed vs the v1 PR
@maiieul flagged that
eager: trueisn't needed (and isn't desirable) on v2. He's right: a compiled MDX/MD file'sdefaultexport is a Qwik component, and the Glob Import recipe explicitly warns thateager: trueon Qwik components makes Vite combine their outputs in a way that breaks Qwik.So the v2 recipe:
eager: true,import: 'frontmatter'(the post component is never pulled in),routeLoader$, then sorts.Imports use the v2 packages (
@qwik.dev/core,@qwik.dev/router).Files
packages/docs/src/routes/docs/cookbook/blog-index/index.mdx— the recipepackages/docs/src/routes/demo/cookbook/blog-index/— the runnable demo (index.tsx+ 3 posts)packages/docs/src/routes/docs/cookbook/index.mdx— overview entry (alphabetized)packages/docs/src/routes/docs/menu.md— sidebar entryTesting
prettier --checkandeslintpass on the touched files.build/v2's own source: thefrontmatternamed export is emitted by the MDX pipeline (packages/qwik-router/src/buildtime/markdown/rehype.ts), and the recipe follows the conventions in the existingglob-importrecipe/demo.pnpm build.core.devrequires the Rust optimizer (napi build), and no Rust toolchain was available. Would appreciate atrigger: preview/ CI render to confirm the demo route end-to-end.Notes
qwik-docsis private, so no changeset (perAGENTS.md).🤖 Generated with Claude Code