English | 简体中文
Weir's personal blog about Linux, networking, cloud-native systems, and system design. The site uses Astro 7, TypeScript, and Markdown. GitHub Actions builds and publishes it to GitHub Pages.
Visit the blog · Subscribe via RSS
- A random quote on the homepage, drawn from 50 quotes by Chinese authors and 50 by authors from elsewhere
- A paginated post list, archives, a tag index, and search
- Markdown posts with syntax highlighting
- An RSS feed, a sitemap, and per-page SEO metadata
- Comments powered by giscus and GitHub Discussions
- Umami analytics for page views, estimated visitors, and referrers, with blog traffic tagged
blog
Use Node.js 22.12.0 or later and npm. The project's .nvmrc selects Node.js 22.
# If you use nvm
nvm install
nvm use
# Install dependencies and start the development server
npm ci
npm run devOpen the address printed in the terminal. The default is http://localhost:4321.
| Command | What it does |
|---|---|
npm run dev |
Starts the development server |
npm run check |
Runs Astro and TypeScript checks |
npm run build |
Builds the static site in dist/ |
npm run preview |
Serves the most recent build locally. Run npm run build first. |
.
├── .github/workflows/deploy.yml # GitHub Pages build and deployment
├── astro.config.mjs # Site URL, Markdown, and sitemap settings
├── public/
│ ├── fonts/ # Quote font subsets, licenses, and maintenance notes
│ ├── img/ # Shared site images
│ └── posts/ # Post images and attachments
├── src/
│ ├── components/ # Post list, pagination, and other components
│ ├── content/posts/ # Markdown posts
│ ├── content.config.ts # Post collection and front matter validation
│ ├── layouts/ # Shared page layouts
│ ├── lib/ # Post utilities and Markdown extensions
│ ├── pages/ # Page routes, RSS feed, and search index
│ └── styles/ # Global styles
└── package.json
src/lib/quotes.ts contains two collections of 50 quotes each, chineseQuotes and foreignQuotes. The latter appear in Chinese translation, and each entry records its source and the wording used there. Refreshing the homepage picks a random quote and avoids showing the same one twice in a row.
The homepage uses a self-hosted subset of LXGW WenKai by default. To see how it compares with Zhuque Fangsong, open /?font=wenkai and /?font=fangsong. Both previews show the same quote. If you add a quote with new characters, rebuild the font subsets using the font maintenance guide (in Chinese).
Create a Markdown file in src/content/posts/, for example hello-world.md.
---
title: "My first post"
date: "2026-01-01T10:00"
tags: ["Linux", "Notes"]
description: "A short introduction to the post."
---
## Getting started
Write your post here.| Front matter field | Required | Description |
|---|---|---|
title |
Yes | Post title |
date |
Yes | Quoted date string in YYYY-MM-DD, YYYY-MM-DDTHH:mm, or YYYY-MM-DDTHH:mm:ss format |
tags |
Yes | Array of tag strings. Use [] for a post without tags. |
description |
Yes | Short summary of the post |
cover |
No | Path to a cover image |
Posts appear newest first. Use lowercase filenames with hyphens between words. For example, hello-world.md is published at /posts/hello-world/.
Put the post's images and attachments in public/posts/hello-world/. Omit the public prefix when referencing them in Markdown.
Run the checks and build the site before publishing.
npm run check
npm run buildsrc/components/Comments.astro embeds giscus at the bottom of each post. Comments are public discussions in the Announcements category of leeweir/leeweir.github.io. Readers sign in with GitHub to participate. GitHub hosts the discussions, so setup requires no separate backend, database, or access token.
The widget loads lazily on post pages and uses Chinese and the light theme. giscus creates a discussion when someone first comments or reacts. You can moderate it in GitHub Discussions.
giscus matches discussions to post paths with strict matching enabled. If you rename or move a post, update the existing discussion's title and giscus matching hash to keep its comments at the new URL.
To enable comments, make the repository public, turn on Discussions, and give the giscus GitHub App access to the repository. If you see giscus is not installed on this repository, go to Settings → Applications → Installed GitHub Apps → giscus → Configure, check Repository access, and save your changes.
To switch repositories or categories, update data-repo, data-repo-id, data-category, and data-category-id in Comments.astro with the values from the giscus configuration page.
The shared layout loads Umami Cloud on every blog page through src/components/Analytics.astro. The blog and the game landing page at /cocoplayroom/ share the Umami website for leeweir.github.io (ID b72a1b50-0b5a-4d61-a9f5-d3878d826048). The tracker tags blog traffic with blog, so the existing website can collect both without an API key. You can rename the website in Umami without affecting collection.
- Sign in to the Umami dashboard.
- In Overview, filter by Tag = blog to see blog Views, estimated Visitors, and Sources → Referrers.
- Open Pages to see traffic per post. For the game landing page, clear the tag filter and set Path = /cocoplayroom/. The unfiltered overview includes both.
The tracker records page views automatically only in production builds served on leeweir.github.io. Local development and preview traffic are excluded. The script uses defer, so readers can continue browsing if the analytics service is unavailable.
Recorded page URLs omit query strings and fragments, including on-site search terms and UTM parameters. Umami uses the referrer supplied by the browser. Direct visits and browsers that omit the referrer have no identifiable source. Visitor counts are estimates.
Tracking starts when the integration goes live. Earlier visits cannot be recovered. The website ID is public, and the reports require sign-in.
Umami tracking script · Tag filters · Tracker configuration
- In the GitHub repository, open Settings → Pages. Under Build and deployment, set Source to GitHub Actions.
- Push to
masteror run the deployment workflow manually from the Actions tab. - The workflow installs dependencies, runs checks, builds the site, and publishes
dist/to GitHub Pages.
The site is configured for the domain root. If you change domains, update site in astro.config.mjs and any references to the old domain, including public/robots.txt. To deploy under a path such as /repository-name/, set Astro's base and adjust root-relative page and asset links.