2024-11-09 20:12:57 +00:00
{{- $id := "" }}
2024-10-15 08:09:14 +00:00
{{- 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 }},
2024-11-09 20:12:57 +00:00
"rel": ["canonical", "alternate"],
2024-10-15 08:09:14 +00:00
"mediaType": "text/html"
}
}
{{- if .Permalink }},
"url": {
"href": "{{.Permalink}}"
{{- with .Language }},
"hreflang": "{{.}}"
{{- end }},
2024-11-09 20:12:57 +00:00
"rel": ["canonical", "alternate"],
2024-10-15 08:09:14 +00:00
"mediaType": "text/html"
}
{{- end }}{{/* end if Permalink */}}
2024-11-09 20:12:57 +00:00
{{- $pages := slice }}
{{- if and (eq .Kind "term") (eq .Type "series") }}
{{- $pages = sort .RegularPages "Params.series_part" "asc" }}
{{- else }}
{{- $pages = .RegularPages }}
{{- end }}
{{- with $pages }},{{- /* 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 }}
2024-11-09 20:12:57 +00:00
{{- if .Date }},
"type": "Article"
{{- else }},
"type": "Page"
{{- end }}
{{- with .Title }},
"name": {{ . | jsonify }}
{{- end }}
{{- with .Summary }},
"summary": {{ . | htmlUnescape | jsonify }}
{{- end }}
{{- with .Date }},
"published": {{ . | jsonify }}
{{- end }}
2024-10-15 08:09:14 +00:00
{{- if .Permalink }},
"url": {
"href": "{{.Permalink}}"
{{- with .Language }},
"hreflang": "{{.}}"
{{- end }},
2024-11-09 20:12:57 +00:00
"rel": ["canonical", "alternate"],
2024-10-15 08:09:14 +00:00
"mediaType": "text/html"
}
{{- end }}{{/* end if Permalink */}}
}{{ if ne $index (sub (len $.Pages) 1)}},{{end}}
{{- end }}{{/* end range Pages */}}
]
{{- end }}{{/* end with Pages */}}
}