tangled-pages#
A simple way to host a website via a tangled repo. You can run it as a cloudflare worker or as an express server.
Setup#
Create a config.json for your site(s).
{
"site": {
"ownerDid": "did:plc:p572wxnsuoogcrhlfrlizlrb",
"repoName": "tangled-pages-example",
"knotDomain": "knot.gracekind.net", // optional, but recommended in workers to avoid an extra request
"branch": "main", // optional, defaults to main
"baseDir": "/public", // optional, defaults to the repo root
"notFoundFilepath": "/404.html" // optional, defaults to text 404
},
"cache": true // server only, not supported in workers (yet)
}
Then:
npm install
npx tangled-pages --config config.json
Example#
You can see an example of a hosted site here.
Configuration#
See config.multiple.example.json for an example of a multi-site config.
If the repo is hosted on tangled.sh, you can use tangledUrl instead of specifying ownerDid and repoName directly.
(This is not recommended in workers since it requires an extra request to resolve the handle.)
E.g.
{
"site": {
"tangledUrl": "https://tangled.sh/@gracekind.net/tangled-pages-example"
}
}
Limitations#
When cache: false, the server fetches files from the repo on every request, so it might be slow.
This library fetches html from the repo directly, so there's no build step. As a workaround, you can add a commit hook to build your site locally and include the built files in your repo (or as a git submodule).
To-do#
- support
cache: truein workers - disk caching
- preloading