Skip to content

docs(cookbook): add blog index recipe (v2)#8679

Open
youcefzemmar wants to merge 1 commit into
QwikDev:build/v2from
youcefzemmar:docs/blog-index-cookbook-v2
Open

docs(cookbook): add blog index recipe (v2)#8679
youcefzemmar wants to merge 1 commit into
QwikDev:build/v2from
youcefzemmar:docs/blog-index-cookbook-v2

Conversation

@youcefzemmar
Copy link
Copy Markdown

What

v2 sister PR to #8671 (which targets main/v1). Adds the Blog Index cookbook recipe — building a listing page from MDX/MD files using import.meta.glob + Qwik Router's frontmatter export — plus a runnable demo at /demo/cookbook/blog-index/ with three sample posts (two .mdx, one .md).

Opened separately on build/v2 at @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: true isn't needed (and isn't desirable) on v2. He's right: a compiled MDX/MD file's default export is a Qwik component, and the Glob Import recipe explicitly warns that eager: true on Qwik components makes Vite combine their outputs in a way that breaks Qwik.

So the v2 recipe:

  • drops eager: true,
  • scopes the glob to the metadata only with import: 'frontmatter' (the post component is never pulled in),
  • resolves the lazy entries server-side in a 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 recipe
  • packages/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 entry

Testing

  • prettier --check and eslint pass on the touched files.
  • Verified against build/v2's own source: the frontmatter named export is emitted by the MDX pipeline (packages/qwik-router/src/buildtime/markdown/rehype.ts), and the recipe follows the conventions in the existing glob-import recipe/demo.
  • I could not run a full live render in my environment: pnpm build.core.dev requires the Rust optimizer (napi build), and no Rust toolchain was available. Would appreciate a trigger: preview / CI render to confirm the demo route end-to-end.

Notes

  • qwik-docs is private, so no changeset (per AGENTS.md).
  • Scoped to docs/cookbook + demo routes; no changes to runtime, build tooling, or starters.

🤖 Generated with Claude Code

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 youcefzemmar requested a review from a team as a code owner May 28, 2026 22:46
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 28, 2026

⚠️ No Changeset found

Latest commit: 6aa694e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@maiieul
Copy link
Copy Markdown
Member

maiieul commented May 29, 2026

@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.

@youcefzemmar
Copy link
Copy Markdown
Author

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:

  • npm run build passes (client build + typecheck + eslint) — no eager-import breakage.
  • GET /blog/ renders 200 with the three posts sorted newest-first (2024-05-20 → 04-15 → 03-01).
  • import: 'frontmatter' resolves correctly — titles/dates/descriptions all show up, and the .md post is picked up alongside the two .mdx ones.
  • All three /blog/posts// pages render 200.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants