I've been slowly making my website more and more Atmospheric. Services like offprint.app, pckt.blog, leaflet.pub, and others have all began to use the standard.site lexicon to give a consistent lexicon for referencing these documents.
1
$type
app.offprint.block.text
plaintext
But each of the apps supports different content blocks and different rendering tasks. There is no shared schema for rendering of documents. The central lexicon is primarily for making posts referenceable across the Atmosphere.
2
$type
app.offprint.block.text
plaintext
I really wanted to use one of these services (or maybe several of these services) as a CMS of sorts. Where I could post on Offprint and have it be mirrored on my website.
3
$type
app.offprint.block.text
facets
0
index
byteEnd
27
byteStart
12
features
0
uri
https://github.com/chrisvander/at-astro-loader
$type
app.offprint.richtext.facet#link
1
index
byteEnd
50
byteStart
35
features
0
$type
app.offprint.richtext.facet#code
plaintext
So, I built a small package called at-astro-loader. We can just build things, I guess!
4
$type
app.offprint.block.heading
level
1
plaintext
First Schema
5
$type
app.offprint.block.text
plaintext
On my website, I have a projects section, which looks like this:
To make my website more Atmospheric, I wanted these projects to be referenced from my PDS. So, I defined a custom lexicon, com.chrisvanderloo.project, with a simple schema that you can find here on PDSLS. There's a great guide on atproto.com that helps with the basics of publishi…
After publishing that, I used lex to install my new lexicon. I used npx -p @atproto/lex lex install com.chrisvanderloo.project . Then, I generated a src/lexicons folder using lex build . Finally, I had a type-safe schema to reference.
9
$type
app.offprint.block.text
facets
0
index
byteEnd
40
byteStart
23
features
0
$type
app.offprint.richtext.facet#code
1
index
byteEnd
193
byteStart
178
features
0
$type
app.offprint.richtext.facet#code
2
index
byteEnd
330
byteStart
326
features
0
$type
app.offprint.richtext.facet#code
plaintext
In Astro, you define a content.config.ts file to create content collections. I wanted my projects to be loaded as a content collection so I could reference it at build. Using my at-astro-loader package, it's pretty easy to set up a content collection based on an installed schema.…
10
code
import { defineCollection } from "astro:content";
import * as com from "./lexicons/com";
import { atLoader } from "at-astro-loader";
const projects = defineCollection({
loader: atLoader(com.chrisvanderloo.project, {
endpoint: "https://bsky.chrisvanderloo.com",
repo: "c…
$type
app.offprint.block.codeBlock
language
ts
11
$type
app.offprint.block.text
plaintext
The above configuration pulls my projects at build time, easy peasy.
12
$type
app.offprint.block.heading
level
1
plaintext
Offprint Posts
13
$type
app.offprint.block.text
plaintext
But now, how do I do this with Offprint posts? I have articles I've written in Markdown, and those are turned into pages at build time. I'd like it to pull Offprint posts as well.
14
$type
app.offprint.block.text
facets
0
index
byteEnd
29
byteStart
14
features
0
$type
app.offprint.richtext.facet#code
plaintext
With 1.2.1 of at-astro-loader, I added support for Offprint documents. The loader is used as follows:
15
code
import { defineCollection } from "astro:content";
import { atLoader, defineStandardSiteDocumentRenderer } from "at-astro-loader";
import { site } from "at-astro-loader/lexicons";
const atprotoBlogCollection = defineCollection({
loader: atLoader(site.standard.document, {
en…
$type
app.offprint.block.codeBlock
language
ts
16
$type
app.offprint.block.text
facets
0
index
byteEnd
203
byteStart
181
features
0
$type
app.offprint.richtext.facet#code
plaintext
You'll note that the lexicon is pulled straight from the package, and we didn't have to install it. Also, there's a "renderer" option. In this case, I've defined a renderer to turn site.standard.document records into HTML. You could define a renderer for any kind of record if des…
17
$type
app.offprint.block.text
plaintext
And, the post you're reading right now was published on Offprint. Looks pretty good, right?
18
$type
app.offprint.block.horizontalRule
19
$type
app.offprint.block.text
plaintext
Let me know if you give my package a shot! I hope I could help to make your Astro site a bit more Atmospheric.
description
How I use content from AT Protocol on my Astro static site.