atproto utils for zig zat.dev
atproto sdk zig
26
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 35 lines 1.8 kB view raw view rendered
1# zat publishes its own docs to ATProto 2 3zat uses itself to publish these docs as `site.standard.document` records. here's how. 4 5## the idea 6 7i'm working on [search for leaflet](https://leaflet-search.pages.dev/) and more generally, search for [standard.site](https://standard.site/) records. many are [currently thinking about how to facilitate better idea sharing on atproto right now](https://bsky.app/profile/eugenevinitsky.bsky.social/post/3mbpqpylv3s2e). 8 9this is me doing a rep of shipping a "standard.site", so i know what i'll be searching through, and to better understand why blogging platforms choose their schema extensions etc for i start indexing/searching their record types. 10 11## what we built 12 13a zig script ([`scripts/publish-docs.zig`](https://tangled.sh/zat.dev/zat/tree/main/scripts/publish-docs.zig)) that: 14 151. authenticates with the PDS via `com.atproto.server.createSession` 162. creates a `site.standard.publication` record 173. publishes each doc as a `site.standard.document` pointing to that publication 184. uses deterministic TIDs so records get the same rkey every time (idempotent updates) 19 20## the mechanics 21 22### TIDs 23 24timestamp identifiers. base32-sortable. we use a fixed base timestamp with incrementing clock_id so each doc gets a stable rkey: 25 26```zig 27const pub_tid = zat.Tid.fromTimestamp(1704067200000000, 0); // publication 28const doc_tid = zat.Tid.fromTimestamp(1704067200000000, i + 1); // docs get 1, 2, 3... 29``` 30 31### CI 32 33[`.tangled/workflows/publish-docs.yml`](https://tangled.sh/zat.dev/zat/tree/main/.tangled/workflows/publish-docs.yml) triggers on `v*` tags. tag a release, docs publish automatically. 34 35`putRecord` with the same rkey overwrites, so the CI job overwrites `standard.site` records when you cut a tag.