Skip to content

astro: support Astro sites without Starlight, with an example site - #14

Merged
ewels merged 3 commits into
mainfrom
astro-without-starlight
Oct 6, 2026
Merged

ewels merged 3 commits into
mainfrom
astro-without-starlight

Conversation

@ewels

@ewels ewels commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Adds first-class support for Astro sites that don't use Starlight, a hosted example site, and docs for both.

  • New starlight-codeblocks/astro integration
    • codeblocks() returns [setup, astroExpressiveCode()]. Astro flattens the array, so Expressive Code sits where the author lists codeblocks(), before mdx(). It replaces expressiveCode() and takes its options under expressiveCode.
    • Reuses the Starlight path: registry, ec-config override for <Code>, Markdown plugin, bundled runtimes. Page CSS goes through injectScript('page-ssr') instead of customCss.
    • Clear build errors when the site also lists expressiveCode(), lists mdx() first, or has an ec.config.mjs plugins list without the preset.
    • The shared helpers move from index.ts to integration.ts; the Starlight plugin behaves as before.
  • Lighter defaults outside Starlight
    • Code tabs and inline code highlighting are off until the site sets codeTabs: {} / inlineHighlighting: {}, because they change every Markdown page.
    • With code tabs on, the integration turns on Sätteri directives and a new restoreDirectives() plugin gives unclaimed directives back as their source text. Without it, 16:9 in prose renders as 16.
    • API card page styles and script (for links outside code blocks, e.g. starlight-pydocs) are never added. Cards inside code blocks still work.
    • tabWidth: 0 stays, as on Starlight.
  • Packaging
    • @astrojs/starlight is now an optional peer dependency, so plain Astro installs get no peer warning.
    • astro-expressive-code is a new optional peer dependency.
    • Prose swatch "Copied" label falls back to system colours without Starlight's variables.
  • Example site in examples/astro/
    • One MDX page with some of the features and a <CodeWalkthrough>, styled like the docs (Starlight palette, Michroma, Night Owl, the homepage code block glow).
    • pnpm docs:build builds it into docs/dist/examples/astro/, so it's hosted with the docs. pnpm test also builds it as a smoke test.
  • Docs
    • Set-up splits into two pages: "Getting started" moves to install/starlight ("Starlight setup"), and a new install/astro ("Astro setup") covers set-up, opt-in options, differences from Starlight and the Expressive Code-only route, plus a LinkCard to the hosted example. Redirects keep /getting-started working.
    • The home page has a button for each set-up page, and its install step is a Starlight/Astro code tabs block.
    • A note at the top of the code tabs and inline code highlighting pages says they need turning on for Astro sites. The Expressive Code plugins reference, the skill, AGENTS.md and DECISIONS.md are updated.
    • Corrects the old claim that <CodeWalkthrough> and <Scrollycoding> need Starlight: both work with only expressiveCode() and the preset.
    • README, npm description and keywords, and the docs home now say "Starlight and Astro".
  • Testing
    • New test/astro.test.ts covers the integration and directive restoring.
    • pnpm lint, pnpm lint:docs, pnpm test and pnpm docs:build pass with no warnings.
    • Checked in a browser in dev and in a preview of docs/dist: run code, code tabs, annotations, placeholders, API cards and the walkthrough, in light and dark themes.

🤖 Generated with Claude Code

ewels and others added 3 commits October 7, 2026 00:56
Add `starlight-codeblocks/astro`, an Astro integration that adds Expressive Code with every feature to a site without Starlight. Code tabs and inline code highlighting are opt-in there, because they change every Markdown page, and unclaimed directives go back to their source text. `@astrojs/starlight` is now an optional peer dependency.

Add a minimal example site in `examples/astro/`, built into the docs at `/examples/astro/`, and an "Astro without Starlight" docs page. Describe the package as a plugin for Starlight and Astro.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Move "Getting started" to install/starlight and "Astro without Starlight" to install/astro, with redirects from the old paths. The home page gets a button for each and a Starlight/Astro code tabs block for the install step. The notes on the code tabs and inline code highlighting pages move to the top.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Remove the install and the extend and reference sections, which the set-up buttons and the sidebar cover, and shorten the hero tagline. The code tabs page no longer points to the home page install command.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ewels
ewels merged commit 013d4c1 into main Oct 6, 2026
3 checks passed
@ewels
ewels deleted the astro-without-starlight branch October 6, 2026 23:31
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