www/layouts/_default/taxonomy.json
Michał Szczepanik a0a37117f0
Enable JSON format for taxonomy pages
This enables generation of JSON format for taxonomy pages, and adds a
simple template which includes:

- permalink: URL of the taxonomy page
- title: title of the taxonomy page
- related: a list or URLs to taxonomy terms

The json can be obtained by adding /index.json to the page URL.

A permalink is currently the only property exposed for each
term (based on the assumption that any additional properties can be
then queried through the term's index.json), but in principle it
should be possible to add more, e.g. title or any other property.
2024-12-13 15:53:54 +01:00

13 lines
437 B
JSON

{{- /* collect permalinks to term-related pages */ -}}
{{- $relatedPermalinks := slice -}}
{{- range .Data.Terms -}}
{{- $relatedPermalinks = $relatedPermalinks | append .Page.Permalink -}}
{{- end -}}
{{/* make a dict of things which aren't in params */}}
{{- $selected := dict
"permalink" .Permalink
"title" .Title
"related" $relatedPermalinks
-}}
{{/* merge those things with params, serve that */}}
{{ $selected | jsonify }}