building a blog using the "islands" design pattern. an sqlite database driven backend that generates a static hypermedia powered modern website.
the scripts loops through the database creating both fully rendered html documents and dom snippets for every page on the site. nginx reads requests and will serve one or the other based on the existence of the hx-request
header.
hx-boost
is employed to automatically hoist all anchor tags to ajax requests, making the magic happen. the response documents contain <title>
tags which htmx recognizes and applies to the page for better UX & SEO.
all build commands are run using bun.
bun install
will pull down all the required dependencies.bun edit
runs the backend server for wysiwyg database management.bun run init
builds thedist
folder structure and moves files into place for the rendered site.bun htmx
will run the typescript to actually generate the site's html assets.bun css
runs the postcss scripts to generate & optimize the site's styling using tailwindscss.bun start
runs init, htmx, and css.
the site's content is generated from a 4 table sqlite database containing: posts, categories, tags, and a relational metadata table that correlates them. database logic exists in: src/models.
html/mustache templates live in: src/views
the main stylesheet is here: src/ui/theme.css. i know i'm using tailwinds "wrong" get outta here.
there are 2 files which define the global domains used. one is for the backend editor the other the blog itself. they default to //localhost
for http fallback support.
the web based wysiwyg editor can be accessed by running bun edit
. the editor supports adding, editing, and removing posts and their meta data, as well as the categories and tags themselves. the default port and hostname (localhost:8999) can be changed in: src/server.ts.
nginx sample configs are available in the nginx directory . the only real "magic" is appending to the root directory on the existence of the hx-request header in the sites-available example.
v1.0 of this project is complete! it's now powering my blog at https://blog.x-e.ro
- nginx alternatives (e.g. caddy)
- nginx hx-header "root rewrite" vs inline hx-get to slug urls perf testing
- idk, maybe actual blogging? •͡˘㇁•͡
(i was thinking about calling this project TNTHUMBS b/c it's built using: typescript nginx tailwindcss htmx unix mustache bun sqlite)
- https://bun.sh/docs
- https://bun.sh/docs/api/sqlite
- https://tailwindcss.com/docs
- https://tailwindcomponents.com/cheatsheet
- https://htmx.org/docs
- https://htmx.org/api
- https://htmx.org/attributes/hx-push-url
- https://www.nerdfonts.com/cheat-sheet
- https://github.com/janl/mustache.js
- http://mustache.github.io/mustache.5.html
all files in this repo, including my blog's content, are released CC0 / kopimi! in the spirit of freedom of information, i encourage you to fork, modify, change, share, or do whatever you like with this project! ^c^v