From 9978b12eacc8889f9a1bd8547c699f9cf4c6a2f7 Mon Sep 17 00:00:00 2001 From: jolheiser Date: Tue, 11 Apr 2023 22:30:13 +0800 Subject: [PATCH] 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 Reviewed-by: Lunny Xiao Co-authored-by: jolheiser Co-committed-by: jolheiser --- config.yaml | 6 ++++++ layouts/index.json | 5 +++++ 2 files changed, 11 insertions(+) create mode 100644 layouts/index.json diff --git a/config.yaml b/config.yaml index 77a102c..0b3e477 100644 --- a/config.yaml +++ b/config.yaml @@ -19,6 +19,12 @@ params: author: Gitea website: https://blog.gitea.io +outputs: + home: + - HTML + - RSS + - JSON + menu: page: - name: Website diff --git a/layouts/index.json b/layouts/index.json new file mode 100644 index 0000000..5aea325 --- /dev/null +++ b/layouts/index.json @@ -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 -}}