Skip to content

feat(docs): add source-backed guide snippets#92

Merged
Exoridus merged 2 commits into
mainfrom
feat/guide-snippet-sources
Jun 5, 2026
Merged

feat(docs): add source-backed guide snippets#92
Exoridus merged 2 commits into
mainfrom
feat/guide-snippet-sources

Conversation

@Exoridus
Copy link
Copy Markdown
Owner

@Exoridus Exoridus commented Jun 4, 2026

Problem

Guide snippets can drift from examples and templates — code is manually duplicated and not type-checked against the real source.

Solution

Source-backed snippet regions with build-time validation:

  • site/src/lib/source-snippets.ts — pure utility with extractSnippetRegion()
  • site/src/components/SourceSnippet.astro — MDX component (SSG, build-time extraction)
  • Region marker convention: // #region guide:<name> / // #endregion guide:<name>
  • Build fails on missing file, missing region, empty region, or duplicate regions

Implementation note

repoRoot() walks up from process.cwd() looking for pnpm-workspace.yaml instead of using import.meta.dirname. This is required because Astro SSG bundles the component into site/dist/.prerender/chunks/, making import.meta.dirname point to the bundle output rather than the source directory.

Scope

Docs/tooling foundation with a small representative migration (~3–4 snippets from orb-dodge walkthrough and first-scene guide).

Validation

  • pnpm typecheck ✓
  • pnpm typecheck:guides ✓
  • pnpm typecheck:examples ✓
  • pnpm test ✓ (1821 tests pass, including 11 new snippet tests)
  • pnpm build ✓
  • pnpm verify:create-exo-app ✓
  • pnpm site:build ✓
  • Error case confirmed (missing region → build error with actionable message)

Exoridus added 2 commits June 5, 2026 01:01
Introduce region-marker extraction so guide code blocks are pulled
directly from type-checked source files instead of being manually
maintained inline. Missing file, missing region, empty region, and
duplicate regions all fail the Astro SSG build with actionable errors.
@Exoridus Exoridus merged commit c6fe698 into main Jun 5, 2026
10 checks passed
@Exoridus Exoridus deleted the feat/guide-snippet-sources branch June 5, 2026 08:36
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.

1 participant