Static site generator and markup for my blog.
This SSG is written in JavaScript and runs under the NodeJS runtime. NodeJS does not understand JSX, nor can it import assets like stylesheets and images as strings using import
syntax. As a result, the project requires two build steps.
The first build step uses a bundler to transpile a JSX-based filesystem description of the blog. It writes a portable script to disk. The second build step runs the script under NodeJS. The script consumes markup from the current working directory to build the blog.
- NodeJS 20
Run the following commands within the repository root:
npm install
# Installs all dependencies
npm run build:project
# Builds the static site generator and writes it to disk as build.js
npm run build:site
# Builds the website itself under /site
Enter Markdown articles in the posts directory with the following structure:
---
title: <TITLE>
tags: <TAG1> <TAG2>
created: <YEAR>-<MONTH>-<DAY>
summary: <RSS SUMMARY>
---
<BODY IN MARKDOWN>
GitHub-Flavoured Markdown is supported, with embedded math and code fragments.
- Wrap inline math in
$
, and block math in$$
- Wrap code in
```
For example, the snippet
# Complex numbers
Python supports complex numbers natively. For example, $1 + 2*j$ is written as
```python
1 + 2j
```
presents inline math, delimited by $
, and fenced code blocks, delimited by ```
.
Run the following commands to format and test code:
npm run format
npm test
GitHub Actions will run tests for every code push.
The output of npm run build:site
can be
- served by a web server such as NGINX, or
- hosted by a platform like GitHub Pages.
A web server, like the one from Python's http.server
module, can be used to preview the blog during development:
python3 -m http.server -d site
# Serves the content of the site folder on localhost:8000