Generates /search-index.json at build time containing title, url, date, and summary for all articles. Template uses Hugo's jsonify and plainify filters for safe JSON output. Includes outputFormats configuration in hugo.toml to enable JSON output format.
Co-Authored-By: Claude Haiku 4.5 <redacted>
theme = "danix-xyz-hacker"
enableRobotsTXT = true
+# Output format definitions
+[outputFormats]
+ [outputFormats.JSON]
+ name = "JSON"
+ mediaType = "application/json"
+ baseName = "search-index"
+ isPlainText = true
+
+# Output formats
+[outputs]
+ home = ["HTML", "JSON"]
+ section = ["HTML"]
+ page = ["HTML"]
+
# Hugo Pipes
[minify]
minifyOutput = false
--- /dev/null
+{{- $articles := where .Site.RegularPages "Section" "articles" -}}
+{{- $articles = $articles.ByDate.Reverse -}}
+[
+ {{- range $index, $article := $articles -}}
+ {
+ "title": {{ $article.Title | jsonify }},
+ "url": {{ $article.Permalink | jsonify }},
+ "date": {{ $article.Date.Format "Jan 02, 2006" | jsonify }},
+ "summary": {{ substr ($article.Summary | plainify) 0 160 | jsonify }}
+ }
+ {{- if ne (add $index 1) (len $articles) }},{{ end }}
+ {{- end }}
+]