|
| 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). |
0 commit comments