Index JSON (#249)

This will expose a JSON endpoint with all the pages and some meta.

It would allow us to, for example, filter posts by `tag` and maybe link to them from our main docs.

e.g. a follow-up PR to tag any "feature preview"-style posts and then link to them from our docs.

Reviewed-on: https://gitea.com/gitea/blog/pulls/249
Reviewed-by: delvh <dev.lh@web.de>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: jolheiser <john.olheiser@gmail.com>
Co-committed-by: jolheiser <john.olheiser@gmail.com>
This commit is contained in:
jolheiser 2023-04-11 22:30:13 +08:00 committed by John Olheiser
parent 223db5bdac
commit 9978b12eac
2 changed files with 11 additions and 0 deletions

View File

@ -19,6 +19,12 @@ params:
author: Gitea
website: https://blog.gitea.io
outputs:
home:
- HTML
- RSS
- JSON
menu:
page:
- name: Website

5
layouts/index.json Normal file
View File

@ -0,0 +1,5 @@
{{- $.Scratch.Add "index" slice -}}
{{- range .Site.RegularPages -}}
{{- $.Scratch.Add "index" (dict "title" .Title "tags" .Params.tags "contents" .Plain "permalink" .Permalink) -}}
{{- end -}}
{{- $.Scratch.Get "index" | jsonify -}}