Static site hosting via tangled
1# tangled-pages
2
3A simple way to host a website via a tangled repo.
4You can run it as a cloudflare worker or as an express server.
5
6## Setup
7
8Create a `config.json` for your site(s).
9
10```json
11{
12 "site": {
13 "ownerDid": "did:plc:p572wxnsuoogcrhlfrlizlrb",
14 "repoName": "tangled-pages-example",
15 "knotDomain": "knot.gracekind.net", // optional, but recommended in workers to avoid an extra request
16 "branch": "main", // optional, defaults to main
17 "baseDir": "/public", // optional, defaults to the repo root
18 "notFoundFilepath": "/404.html" // optional, defaults to text 404
19 },
20 "cache": true // server only, not supported in workers (yet)
21}
22```
23
24Then:
25
26```bash
27npm install
28npx tangled-pages --config config.json
29```
30
31## Example
32
33You can see an example of a hosted site [here](https://tangled-pages-example.gracekind.net).
34
35## Configuration
36
37See `config.multiple.example.json` for an example of a multi-site config.
38
39If the repo is hosted on tangled.sh, you can use `tangledUrl` instead of specifying `ownerDid` and `repoName` directly.
40(This is not recommended in workers since it requires an extra request to resolve the handle.)
41
42E.g.
43
44```json
45{
46 "site": {
47 "tangledUrl": "https://tangled.sh/@gracekind.net/tangled-pages-example"
48 }
49}
50```
51
52## Limitations
53
54When `cache: false`, the server fetches files from the repo on every request, so it might be slow.
55
56This 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).
57
58## To-do
59
60- support `cache: true` in workers
61- disk caching
62- preloading