From fa4d0052d7c774217dabe0792ee5f6af3f61b101 Mon Sep 17 00:00:00 2001 From: Dinis Cruz Date: Sun, 8 Dec 2024 23:01:07 +0000 Subject: [PATCH] added default view which outputs the entire content of the site in one JSON --- config/_default/config.toml | 7 ++++- layouts/_default/list.content.json | 48 ++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 layouts/_default/list.content.json diff --git a/config/_default/config.toml b/config/_default/config.toml index 23ffb8c28d1..54bbf5dce13 100644 --- a/config/_default/config.toml +++ b/config/_default/config.toml @@ -27,12 +27,17 @@ paginate = 10 blog = "/blog/:year/:month/:day/:filename/" [outputs] -home = [ "HTML", "Algolia"] +home = [ "HTML", "Algolia", "Content"] [outputFormats.Algolia] baseName = "algolia" isPlainText = true mediaType = "application/json" + +[outputFormats.Content] +baseName = "content" +isPlainText = true +mediaType = "application/json" notAlternative = true [params.algolia] diff --git a/layouts/_default/list.content.json b/layouts/_default/list.content.json new file mode 100644 index 00000000000..cce1d792273 --- /dev/null +++ b/layouts/_default/list.content.json @@ -0,0 +1,48 @@ +{{/* Generates dump of the site's content */}} +{{- $.Scratch.Add "index" slice -}} +{{- $section := $.Site.GetPage "section" .Section }} +{{- range .Site.AllPages -}} + {{- if or (and (.IsDescendant $section) (and (not .Draft) (not .Params.private))) $section.IsHome -}} + {{- if .File -}} + {{- $.Scratch.Add "index" (dict "objectID" .File.UniqueID + "date" .Date.UTC.Unix + "description" .Description + "dir" .File.Dir + "expirydate" .ExpiryDate.UTC.Unix + "fuzzywordcount" .FuzzyWordCount + "keywords" .Keywords + "kind" .Kind + "lang" .Lang + "lastmod" .Lastmod.UTC.Unix + "permalink" .Permalink + "publishdate" .PublishDate + "readingtime" .ReadingTime + "relpermalink" .RelPermalink + "summary" .Summary + "title" .Title + "type" .Type + "url" .RelPermalink + "weight" .Weight + "wordcount" .WordCount + "section" .Section + "tags" .Params.Tags + "categories" .Params.Categories + "authors" .Params.Authors + "track" .Params.track + "project" .Params.project + "topics" .Params.topics + "event" .Params.event + "when_year" .Params.when_year + "when_month" .Params.when_month + "when_day" .Params.when_day + "when_time" .Params.when_time + "hey_summit" .Params.hey_summit + "session_slack" .Params.session_slack + "organizers" .Params.organizers + "youtube_link" .Params.youtube_link + "zoom_link" .Params.zoom_link + "content" .Content)}} + {{- end -}} + {{- end -}} +{{- end -}} +{{- $.Scratch.Get "index" | jsonify -}} \ No newline at end of file