Skip to content

Commit c820251

Browse files
cursoragentschacon
andcommitted
Add Astro project site with readable, searchable book, blog, and history
- site/: Astro 7 project — homepage, MDX blog, history page, and the full book rendered one page per section from the AsciiDoc sources via Asciidoctor.js (same splitting strategy as builder/src/site.rs) - Full-text search over book and blog with Pagefind - .github/workflows/deploy-site.yml: build on push to main and publish site/dist to the gh-pages branch Co-authored-by: Scott Chacon <schacon@gmail.com>
1 parent e18f0a4 commit c820251

24 files changed

Lines changed: 8499 additions & 0 deletions

.github/workflows/deploy-site.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Deploy site to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
11+
concurrency:
12+
group: deploy-site
13+
cancel-in-progress: true
14+
15+
jobs:
16+
deploy:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v7
20+
with:
21+
# Full history so the build can derive the revision number from tags
22+
# and the contributors list from the shortlog.
23+
fetch-depth: 0
24+
25+
- name: Set up Node
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 22
29+
cache: npm
30+
cache-dependency-path: site/package-lock.json
31+
32+
- name: Install dependencies
33+
working-directory: site
34+
run: npm ci
35+
36+
- name: Build site
37+
working-directory: site
38+
run: npm run build
39+
40+
- name: Publish to gh-pages
41+
uses: peaceiris/actions-gh-pages@v4
42+
with:
43+
github_token: ${{ secrets.GITHUB_TOKEN }}
44+
publish_branch: gh-pages
45+
publish_dir: site/dist
46+
force_orphan: true

site/.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# dependencies
2+
node_modules/
3+
4+
# build output
5+
dist/
6+
.astro/
7+
8+
# generated by scripts/build-book.mjs
9+
src/generated/
10+
public/images/
11+
public/book-cover.png
12+
public/favicon.ico

site/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Pro Git project site
2+
3+
The source for the project website, built with [Astro](https://astro.build). It has:
4+
5+
- a **homepage** introducing the book,
6+
- the **full book, readable online** — one page per section, rendered from the
7+
AsciiDoc sources in this repository with
8+
[Asciidoctor.js](https://github.com/asciidoctor/asciidoctor.js),
9+
- **full-text search** over the book and blog, powered by
10+
[Pagefind](https://pagefind.app),
11+
- a **blog** (MDX, in `src/content/blog/`) for updates and progress on the
12+
third edition,
13+
- a **history of the book** page.
14+
15+
## How the book gets onto the site
16+
17+
`scripts/build-book.mjs` runs before every dev/build. It converts `../progit.asc`
18+
(including all chapter includes) to HTML, splits the result into one page per
19+
section — the same strategy as `builder/src/site.rs` — rewrites cross-references
20+
and image paths, and writes:
21+
22+
- `src/generated/book.json` — consumed by `src/pages/book/[slug].astro`,
23+
- `public/images/`, `public/book-cover.png`, `public/favicon.ico` — copied from
24+
the repository.
25+
26+
All of those outputs are git-ignored; the book is never duplicated in the repo.
27+
28+
## Commands
29+
30+
Run these from the `site/` directory:
31+
32+
| Command | Action |
33+
| ----------------- | ------------------------------------------------------------ |
34+
| `npm install` | Install dependencies |
35+
| `npm run dev` | Regenerate the book, then start the dev server |
36+
| `npm run build` | Regenerate the book, build to `dist/`, index it with Pagefind |
37+
| `npm run preview` | Serve the built `dist/` locally |
38+
39+
Note: search only works on the *built* site (`npm run build` + `npm run preview`),
40+
because Pagefind indexes the generated HTML.
41+
42+
## Writing a blog post
43+
44+
Add an `.mdx` file to `src/content/blog/` with this frontmatter:
45+
46+
```mdx
47+
---
48+
title: 'Post title'
49+
description: 'One-sentence summary shown in lists and search results.'
50+
date: 2026-08-02
51+
author: 'Your Name' # optional
52+
---
53+
54+
Post body in MDX…
55+
```
56+
57+
The file name (without `.mdx`) becomes the URL: `/blog/<file-name>/`.
58+
59+
## Deployment
60+
61+
`.github/workflows/deploy-site.yml` builds the site on every push to `main` and
62+
publishes `site/dist/` to the `gh-pages` branch with
63+
[peaceiris/actions-gh-pages](https://github.com/peaceiris/actions-gh-pages).
64+
Point GitHub Pages at the `gh-pages` branch (Settings → Pages → Deploy from a
65+
branch) and the site is served at <https://progit.github.io/progit3/>.
66+
67+
The canonical URL and base path default to `https://progit.github.io` and
68+
`/progit3`; override them with the `SITE_URL` and `BASE_PATH` environment
69+
variables (e.g. for a fork or a custom domain).

site/astro.config.mjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// @ts-check
2+
import { defineConfig } from 'astro/config';
3+
import mdx from '@astrojs/mdx';
4+
5+
// GitHub Pages project site: https://progit.github.io/progit3/
6+
// Override SITE_URL / BASE_PATH for forks or a custom domain.
7+
const site = process.env.SITE_URL ?? 'https://progit.github.io';
8+
const base = process.env.BASE_PATH ?? '/progit3';
9+
10+
export default defineConfig({
11+
site,
12+
base,
13+
trailingSlash: 'ignore',
14+
integrations: [mdx()],
15+
build: {
16+
format: 'directory',
17+
},
18+
});

0 commit comments

Comments
 (0)