add-preview-route
Add a new component showcase, block, or template preview page and register it everywhere it must appear (navigation, command palette, route lists, SEO, source view). Use when adding anything under /co
SKILL.md.claude/skills/add-preview-route/SKILL.md
GitHubAdd a preview route: $ARGUMENTS
Preview pages render inside the editor's iframe (?preview, preview layout) and must respond to the theme being edited. Use Nuxt UI components and semantic tokens (bg-(--ui-bg-elevated), text-(--ui-text-muted), color="primary"), never raw palette classes like bg-blue-500.
1. Create the content
Component showcase (/components/<slug>, data-driven via app/pages/components/[slug].vue):
- Create
app/components/showcase/components/<PascalSlug>.vue. It's resolved byimport.meta.globfrom the kebab-case slug. ReuseShowcaseSpecimen/ShowcaseSpecimenGridlike the existing showcases. - Register it in
COMPONENT_CATEGORIESinapp/utils/navigation/components.ts(label, icon, description,to: "/components/<slug>").
Block (/blocks/<slug>, data-driven via app/pages/blocks/[slug].vue):
- Variants live in
app/components/blocks/components/<Name>.vue. Each block page isapp/components/blocks/content/<PascalSlug>.vue, fed byapp/data/blocks/<slug>.ts, which imports every variant and its?rawsource (shown in the block's code view) plus an AIprompt. - Register it in
BLOCK_CATEGORIESinapp/utils/navigation/blocks.ts.
Template (/templates/<slug>):
- Create
app/pages/templates/<slug>.vueas a full, self-contained page (users copy this file from the source view, so keep it clean and idiomatic). Don't usedefinePageMeta({ layout });app.vuepicks layouts. - Register it in
TEMPLATE_CATEGORIESinapp/utils/navigation/templates.ts. - Source view picks it up automatically via
modules/source-code-embed.ts. Restartpnpm devto refresh the embedded map.
2. Register the route
shared/constants/routes.ts: add the path toCOMPONENT_ROUTES/BLOCK_ROUTES/TEMPLATE_ROUTES. These drive the sitemap, prerendering, andnoindex.tests/unit/shared/routes.test.tsfails if nav and route lists disagree.app/utils/seoDescriptions.ts: add aPAGE_DESCRIPTIONSentry (andPAGE_TITLESif the generic "<Label> Component/Block/Template" title isn't right).- The command palette and breadcrumbs read the navigation modules, so no extra work is needed there.
3. Verify
pnpm vitest run tests/unit/shared/routes.test.ts tests/unit/utils/navigation.test.ts tests/unit/utils/seoDescriptions.test.ts/run-app: open the route in the editor, change the primary color and radius and confirm the preview reacts, toggle dark mode, use the command palette to find it, and for templates check the source view./dev-workflow.