Files
awesome-copilot/website/astro.config.mjs
T
Aaron Powell f29b88f27f feat(website): rebuild site on Primer Brand design prototype
Replace the Astro + Starlight site with the Brand Engineering design
prototype, ported component-for-component onto plain Astro + React
islands. The prototype is treated as the authority on markup and
styling; dynamic data is injected into its components rather than the
components being reinterpreted.

Framework:
- Remove @astrojs/starlight entirely, along with its document shell,
  search, footer and language selector. BaseLayout.astro now owns the
  document head, CSP, social meta and analytics.
- Add @primer/react-brand and @astrojs/react. Alias the package to its
  ESM build in vite.resolve, since the default CJS entrypoint breaks
  named-export detection during SSR, and mark it noExternal so its
  stylesheet imports resolve.
- Promote pagefind to an explicit devDependency; it was previously
  pulled in transitively by Starlight.

Pages: home, the five catalogs, the five detail routes, contributors,
Playbook index and articles, and the cookbook are all rendered by
ported prototype components inside a shared PageShell.

Detail pages share a DetailChassis (hero, breadcrumbs, sticky TOC with
scroll-spy, prev/next) while keeping what makes each type distinct: a
file switcher over bundled skill assets, an included-items grid and
external provenance for plugins, and a hero-scale preview for
extensions.

i18n: resolve translated Playbook entries via Astro.currentLocale
inside the shared article route instead of separate [locale] routes.
The explicit routes collided with the i18n fallback routes, so
translated articles were being shadowed by their English originals and
900 nonsensical double-locale pages were emitted.

Search: TopNavSearch now queries the Pagefind index client-side in
addition to the static resource index, merging on href and degrading
to the static index in dev, where no index has been built.

Also delete the superseded vanilla-TS page renderers and Astro
partials, which the ported React components fully replace.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 80686fef-efe3-4cdd-8cd6-bfa61a5d0af6
2026-08-14 17:32:36 +10:00

86 lines
2.8 KiB
JavaScript

import sitemap from "@astrojs/sitemap";
import react from "@astrojs/react";
import { defineConfig } from "astro/config";
import remarkGithubAdmonitionsToDirectives from "remark-github-admonitions-to-directives";
import pagefindResources from "./src/integrations/pagefind-resources";
// Playbook course content mirrored from external workshop repos is authored in
// GitHub admonition syntax (`> [!NOTE]`). This remark plugin rewrites those
// callouts into directives before rendering, so the same syntax used in the
// source repos and on github.com also produces styled callouts here.
const githubAdmonitionMapping = {
NOTE: "note",
TIP: "tip",
IMPORTANT: "note",
WARNING: "caution",
CAUTION: "caution",
};
const site = "https://awesome-copilot.github.com/";
// https://astro.build/config
export default defineConfig({
site,
base: "/",
output: "static",
markdown: {
remarkPlugins: [
[remarkGithubAdmonitionsToDirectives, { mapping: githubAdmonitionMapping }],
],
},
// English is served at the site root (no locale prefix), preserving all
// existing URLs. Additional locales are served under a locale prefix
// (e.g. /es-es/…) and fall back to the English page when a translation does
// not yet exist. These keys match the locale directory names used by mirrored
// Playbook course content (website/src/content/docs/<locale>/…).
i18n: {
defaultLocale: "en",
locales: ["en", "es-es", "ja-jp", "ko-kr", "pt-br", "zh-cn"],
routing: {
prefixDefaultLocale: false,
fallbackType: "rewrite",
},
fallback: {
"es-es": "en",
"ja-jp": "en",
"ko-kr": "en",
"pt-br": "en",
"zh-cn": "en",
},
},
integrations: [react(), sitemap(), pagefindResources()],
redirects: {
"/samples/": "/learning-hub/cookbook/",
},
build: {
assets: "assets",
},
trailingSlash: "always",
vite: {
// @primer/react-brand's default entrypoint is CJS, so Node's ESM loader
// cannot detect its named exports during SSR. The package also ships a
// proper ESM build; alias to it so named imports resolve in both the
// server render and the client bundle.
resolve: {
alias: [
{
// Only the bare package specifier (the JS entrypoint) is redirected;
// subpath imports such as `/lib/css/main.css` must resolve normally.
find: /^@primer\/react-brand$/,
replacement: "@primer/react-brand/esm",
},
],
// The ESM build imports its own .css files, which Node's loader cannot
// handle, so it has to be bundled rather than externalised for SSR.
noExternal: ["@primer/react-brand"],
},
build: {
sourcemap: false,
chunkSizeWarningLimit: 900,
},
css: {
devSourcemap: true,
},
},
});