99 lines
No EOL
2.7 KiB
Text
99 lines
No EOL
2.7 KiB
Text
{{- $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", "alternate"],
|
|
"mediaType": "text/html"
|
|
}
|
|
}
|
|
{{- if .Permalink }},
|
|
"url": {
|
|
"href": "{{.Permalink}}"
|
|
{{- with .Language }},
|
|
"hreflang": "{{.}}"
|
|
{{- end }},
|
|
"rel": ["canonical", "alternate"],
|
|
"mediaType": "text/html"
|
|
}
|
|
{{- end }}{{/* end if Permalink */}}
|
|
{{- $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 */}}
|
|
"orderedItems": [
|
|
{{- range $index, $item := . }}
|
|
{{- $itemId := "" }}
|
|
{{- with .OutputFormats.Get "as2" }}
|
|
{{- $itemId = .Permalink }}
|
|
{{- end }}
|
|
{
|
|
{{- with $itemId }}
|
|
"id": "{{ . }}"
|
|
{{- end }}
|
|
{{- if .Date }},
|
|
"type": "Article"
|
|
{{- else }},
|
|
"type": "Page"
|
|
{{- end }}
|
|
{{- with .Title }},
|
|
"name": {{ . | jsonify }}
|
|
{{- end }}
|
|
{{- with .Summary }},
|
|
"summary": {{ . | htmlUnescape | jsonify }}
|
|
{{- end }}
|
|
{{- with .Date }},
|
|
"published": {{ . | jsonify }}
|
|
{{- end }}
|
|
{{- if .Permalink }},
|
|
"url": {
|
|
"href": "{{.Permalink}}"
|
|
{{- with .Language }},
|
|
"hreflang": "{{.}}"
|
|
{{- end }},
|
|
"rel": ["canonical", "alternate"],
|
|
"mediaType": "text/html"
|
|
}
|
|
{{- end }}{{/* end if Permalink */}}
|
|
}{{ if ne $index (sub (len $.Pages) 1)}},{{end}}
|
|
{{- end }}{{/* end range Pages */}}
|
|
]
|
|
{{- end }}{{/* end with Pages */}}
|
|
} |