Skip to content

Commit 104b871

Browse files
committed
feat: setup outbox generation
1 parent b7824e0 commit 104b871

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

config.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,16 @@ url = "/index.xml"
107107
[taxonomies]
108108
tag = "tags"
109109
category = "categories"
110+
111+
[mediaTypes]
112+
[mediaTypes."application/activity+json"]
113+
suffixes = ["ajson"]
114+
115+
[outputFormats]
116+
[outputFormats.ACTIVITY_OUTBOX]
117+
mediaType = "application/activity+json"
118+
notAlternative = true
119+
baseName = "outbox"
120+
121+
[outputs]
122+
home = ["HTML", "RSS", "ACTIVITY_OUTBOX"]
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{{- $pctx := . -}}
2+
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
3+
{{- $pages := slice -}}
4+
{{- if or $.IsHome $.IsSection -}}
5+
{{- $pages = $pctx.RegularPages -}}
6+
{{- else -}}
7+
{{- $pages = $pctx.Pages -}}
8+
{{- end -}}
9+
{{- $limit := .Site.Config.Services.RSS.Limit -}}
10+
{{- if ge $limit 1 -}}
11+
{{- $pages = $pages | first $limit -}}
12+
{{- end -}}
13+
{
14+
"@context": "https://www.w3.org/ns/activitystreams",
15+
"id": "{{ $.Site.BaseURL }}outbox",
16+
"summary": "{{$.Site.Title}}",
17+
"type": "OrderedCollection",
18+
{{ $notdrafts := where $pages ".Draft" "!=" true }}
19+
{{ $all := where $notdrafts "Type" "in" "posts"}}
20+
"totalItems": {{(len $all)}},
21+
"orderedItems": [
22+
{{ range $index, $element := $all }}
23+
{{- if ne $index 0 }}, {{ end }}
24+
{
25+
"@context": "https://www.w3.org/ns/activitystreams",
26+
"id": "{{.Permalink}}-create",
27+
"type": "Create",
28+
"actor": "https://msfjarvis.dev/blog",
29+
"object": {
30+
"id": "{{ .Permalink }}",
31+
"type": "Note",
32+
"content": "{{.Title}}<br>{{.Summary}}",
33+
"url": "{{.Permalink}}",
34+
"attributedTo": "https://msfjarvis.dev/blog",
35+
"to": "https://www.w3.org/ns/activitystreams#Public",
36+
"published": {{ dateFormat "2006-01-02T15:04:05-07:00" .Date | jsonify }}
37+
}
38+
}
39+
{{end}}
40+
]
41+
}

netlify.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,8 @@ Content-Type = "application/xml; charset=utf-8"
5050
for = "/@blog"
5151
[headers.values]
5252
Content-Type = "application/activity+json; charset=utf-8"
53+
54+
[[headers]]
55+
for = "/outbox.ajson"
56+
[headers.values]
57+
Content-Type = "application/activity+json; charset=utf-8"

0 commit comments

Comments
 (0)