2024-10-15 08:09:14 +00:00
{{ $id := "" }}
{{- with .OutputFormats.Get "as2" -}}
{{- $id = .Permalink }}
{{- end }}
{{- $type := slice "OrderedCollection" -}}
{
"@context": "https://www.w3.org/ns/activitystreams"
{{- with $id }},
"id": "{{ . }}"
{{- end }}{{/* with id */}}
{{- with $type }}
{{- if eq (. | len) 1 }},{{/* single type */}}
"type": "{{index . 0}}"
{{- else }},{{/* multiple types */}}
"type": {{ . | jsonify }}
{{- end }}{{/* end if single type */}}
{{- end }}{{/* end with $type */}}
{{- with .Title | jsonify }},
"name": {{.}}
{{- end }}{{/* end with Title */}}
{{- if .Params.summary }}{{/* only consider explicitly-set summaries */}}
{{- with .Summary | jsonify }},
"summary": {{.}}
{{- end }}{{/* end with Summary */}}
{{- end }}{{/* end if Params.summary */}},
"attributedTo": { {{/* TODO: make this variable instead of hardcoded */}}
{{- $ownerId := "" }}
{{- with .Site.Home.OutputFormats.Get "as" }}
{{- $ownerId = .Permalink }}
{{- end }}
{{- with $ownerId }}
"id": "{{ $ownerId }}",
{{ end }}
"type": "Person",
"url": {
"href": "{{.Site.Home.Permalink}}"
{{- with .Language }},
"hreflang": "{{.}}"
{{- end }},
"rel": "canonical",
"mediaType": "text/html"
}
}
{{- if .Permalink }},
"url": {
"href": "{{.Permalink}}"
{{- with .Language }},
"hreflang": "{{.}}"
{{- end }},
"rel": "canonical",
"mediaType": "text/html"
}
{{- end }}{{/* end if Permalink */}}
2024-10-16 05:34:37 +00:00
{{- with .RegularPages }},{{- /* TODO: make a separate section.as2.jsonld template for sections that gets all RegularPages in CurrentSection? or otherwise detect sections in this template */}}
2024-10-15 08:09:14 +00:00
"orderedItems": [
{{- range $index, $item := . }}
{{- $itemId := "" }}
{{- with .OutputFormats.Get "as2" }}
{{- $itemId = .Permalink }}
{{- end }}
{
{{- with $itemId }}
"id": "{{ . }}"
{{- end }}
{{- if .Permalink }},
"url": {
"href": "{{.Permalink}}"
{{- with .Language }},
"hreflang": "{{.}}"
{{- end }},
"rel": "canonical",
"mediaType": "text/html"
}
{{- end }}{{/* end if Permalink */}}
}{{ if ne $index (sub (len $.Pages) 1)}},{{end}}
{{- end }}{{/* end range Pages */}}
]
{{- end }}{{/* end with Pages */}}
}