Set up Astro with GitHub Pages, migrate homepage, and publish docs as site pages#1966
Set up Astro with GitHub Pages, migrate homepage, and publish docs as site pages#1966pmcelhaney merged 9 commits intomainfrom
Conversation
Agent-Logs-Url: https://github.com/counterfact/api-simulator/sessions/43628429-220a-4b27-8e3f-46cb6a0c81e2 Co-authored-by: pmcelhaney <51504+pmcelhaney@users.noreply.github.com>
pmcelhaney
left a comment
There was a problem hiding this comment.
Extract the inline CSS and JS into files.
Agent-Logs-Url: https://github.com/counterfact/api-simulator/sessions/daa2911f-811d-4bc5-958c-7eab9c30187a Co-authored-by: pmcelhaney <51504+pmcelhaney@users.noreply.github.com>
Done in commit 27e46fe. The inline CSS is now in Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
| @@ -0,0 +1,33 @@ | |||
| function copyCmd() { | |||
pmcelhaney
left a comment
There was a problem hiding this comment.
The index page currently links to GitHub.com
Instead of linking to Github, I want all of the files under docs to be published to the web site.
Agent-Logs-Url: https://github.com/counterfact/api-simulator/sessions/a5fe156d-85a0-441e-aa8c-05215f78cec8 Co-authored-by: pmcelhaney <51504+pmcelhaney@users.noreply.github.com>
Done in commit b94cd42. All Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
pmcelhaney
left a comment
There was a problem hiding this comment.
Some of the links end in .md and some do not. I need all of the links to end in .md so that the links will still work on Github and I also need Astro to still work. I imagine the best way to do that is to keep the .md extensions in the source and strip them in the build. But if there's another standard way to solve this problem, do that.
…urce consistency Agent-Logs-Url: https://github.com/counterfact/api-simulator/sessions/a80d1491-c25e-47d8-92a1-e7c33f4ae0d9 Co-authored-by: pmcelhaney <51504+pmcelhaney@users.noreply.github.com>
Done in commit 56e798b. The approach:
Build generates 99 pages (1 homepage + 49 clean doc URLs + 49 Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
pmcelhaney
left a comment
There was a problem hiding this comment.
eslint is failing on new files created under the site directory. Exclude the site directory from eslint.
Done in commit 0c27b48. Added a dedicated |
Migrates the counterfact.dev homepage from Jekyll to Astro, deploying via GitHub Actions to GitHub Pages. The new-homepage branch's
docs/index.htmlbecomes the foundation. All markdown files underdocs/are published as styled pages on the site, with.mdlinks preserved in source (works on GitHub) and stripped at build time.Summary
Introduces a self-contained Astro v5 project under
site/with a layout/page split, wires up official GitHub Pages deployment, and migrates the dark-themed homepage HTML. CSS and JavaScript are kept in their own source files and bundled by Vite during build. An Astro content collection with a glob loader publishes every.mdfile underdocs/as a page at/docs/<slug>. All doc links in the source use.mdextensions so they remain clickable on GitHub; a custom rehype plugin strips those extensions at build time so the site URLs are clean. Each doc page is also served at its.md-suffixed URL (e.g./docs/getting-started.md) with a canonical link pointing to the clean URL. Thesite/directory is excluded from the root ESLint configuration so its Astro/Vite-specific files are not linted by the project-level rules.Original Prompt
We want to move this site to Astro and deploy it via GitHub Pages, using the existing
index.htmlfrom thenew-homepagebranch as the foundation.This should be done in a way that preserves the current homepage content while setting us up for future expansion (docs, additional pages, etc.).
Goals
index.html(fromnew-homepage) into an Astro layout/template/)Manual acceptance tests
cd site && npm install && npm run dev— homepage renders with correct dark theme, nav, hero, and code sectionscd site && npm run build— exits 0,site/dist/containsindex.html,counterfact.svg,CNAME, and adocs/directory with HTML pages for every markdown file underdocs/npm run preview— no broken assets, fonts load, SVG logo appears, nav "Docs" link opens/docs/getting-started(not GitHub)main—Deploy Site to GitHub Pagesworkflow passes in Actionsnew-homepagebranch'sdocs/index.html/docs/getting-startedto/docs/patterns) — navigates correctly with no.mdin the URLdocs/*.mdfile directly on GitHub — all cross-document links resolve correctly (.mdextensions intact in source)Tasks
site/Astro project —package.json(astro v5.18.1),astro.config.mjs(static output,site: "https://counterfact.dev"),tsconfig.json,.gitignoresite/src/layouts/MainLayout.astro— HTML shell with<head>, Google Fonts links,import "../styles/main.css", and optionalcanonicalPathprop that emits<link rel="canonical">; exposes optionaltitlepropsite/src/styles/main.css— ~900 lines of CSS extracted from the original inline<style>blocksite/src/pages/index.astro— full body content fromnew-homepage/docs/index.html; curly braces in code examples escaped as{/}; references../scripts/main.jsvia<script> import </script>; doc links use.mdextensions (e.g./docs/getting-started.md)site/src/scripts/main.js— clipboard copy andIntersectionObserverJS extracted from the original inline<script>blocksite/src/content.config.ts— Astro v5 content collection using glob loader, pointing to../docs; publishes all**/*.mdfiles as thedocscollectionsite/src/pages/docs/[...slug].astro— dynamic route generating two static pages per doc: a clean URL (/docs/<slug>) and a.md-alias URL (/docs/<slug>.md), both with<link rel="canonical">pointing to the clean URL; page title extracted from the first# H1heading with a slug-derived fallbacksite/src/layouts/DocLayout.astro— dark-theme prose layout wrappingMainLayout; includes "← Home" breadcrumb and styled typography; forwardscanonicalPathtoMainLayoutsite/astro.config.mjs— custom rehype pluginrehypeStripMdLinksstrips.mdextensions (including?queryand#anchorvariants) from localhrefattributes when markdown is rendered to HTML; protocol URLs (://,mailto:,tel:) are left untouchedsite/public/—CNAME(counterfact.dev) andcounterfact.svg; imagesrcupdated from./counterfact.svg→/counterfact.svg.github/workflows/deploy-site.yaml— triggers onmainpush andworkflow_dispatch; uses Node 22,npm ci, and the officialconfigure-pages/upload-pages-artifact/deploy-pagesaction chain.gitignore— excludessite/node_modules,site/dist,site/.astrodocs/index.html— synced to thenew-homepagebranch versioneslint.config.cjs— added a dedicated{ ignores: ["site/**"] }entry so the root ESLint run skips all files undersite/; placed as a standalone object (ESLint flat config requiresignores-only objects for global file exclusions)