- Notifications
You must be signed in to change notification settings - Fork0
markbeep/htmx-blog
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This is mypersonal blog. It started out as a simple project to practice usinghtmx to makeit an extremely lightweight and efficient website andtailwindcss for the styling.
One important requirement was that all my blog posts were to be written in markdown (in/content
). It then turned out to bea bigger challenge to get the markdown file generation working than actually creating the blog. I first started out usingpandocto generate the markdown externally, but pandoc does some very weird styling and the syntax highlighting colors they support lookreally bad. I instead then opted forgoldmark which is also in use by thehugo.
To get the blog running locally you first needgo 1.21
. You'll also needtempl which has three quick ways to install:
go install github.com/a-h/templ/cmd/templ@latest# install via gocurl -o https://github.com/a-h/templ/releases/download/v0.2.432/templ_Linux_x86_64.tar.gz&& chmod +x templ# install binarynix run github:a-h/templ# run using nix
Once templ and go is set, you can generate the template go files and then start the server:
templ generatego run.
For the best developer experience I recommend gettingair which enables hot-reloading on save. Install air and run it:
go install github.com/cosmtrek/air@latestair
If you're working on the css or styling, it is recommended to also get thetailwindcss CLI tool and run it on the side to keep on updatingthemain.css
stylesheet:
tailwindcss -i static/tw.css -o static/main.css --watch
It's also possible to start up the website usingDocker:
docker compose up --build
This will build and start up the website as well as run the playwright tests. If you're building for arm64, you'll need to modify the Dockerfile and swap outthe tailwindcss CLI tool installation for the arm64 version.
For extensive testing,Playwright is used. To make the install simpler, there's a Dockerfileine2e/Dockerfile.playwright
. Build and run it from theroot directory.
docker build -t htmx-playwright -f e2e/Dockerfile.playwright.docker run --rm -it --network host htmx-playwright /bin/bash
With theflake.nix
andflake.lock
files you can set up local development with the exact same dependency versions.
nix develop# downloads all required dependenciesnix build .#htmx-blog # build the blognix run .#htmx-blog # build and run the blog locallynix run .#tailwindcss -- -i static/tw.css -o static/main.css --watch
Note: Tailwindcss still needs to be executed manually on the side to generate thestatic/main.css
file
Posts can be created by executing thepost.sh
script. Simply execute the following:
./post.sh content/posts/name_of_post