From 72ccecdc5b8bd5fef140c706902eb2139068d748 Mon Sep 17 00:00:00 2001
From: amzrk2
Date: Sun, 14 Jun 2020 23:30:00 +0800
Subject: Generate json for searching

---
 exampleSite/config.toml     | 2 ++
 layouts/_default/index.json | 5 +++++
 2 files changed, 7 insertions(+)
 create mode 100644 layouts/_default/index.json

diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 72e22b7..7df8ba0 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -2,6 +2,8 @@ baseURL = "https://example.com"
 title = "Hugo Theme Fuji"
 
 theme = "fuji"
+[outputs]
+  home = ["html", "rss", "json"]
 hasCJKLanguage = true
 enableEmoji = true
 enableRobotsTXT = true
diff --git a/layouts/_default/index.json b/layouts/_default/index.json
new file mode 100644
index 0000000..a823e62
--- /dev/null
+++ b/layouts/_default/index.json
@@ -0,0 +1,5 @@
+{{- $.Scratch.Add "search" slice -}}
+{{- range (where .Site.RegularPages "Type" "in" .Site.Params.mainSections) -}}
+    {{- $.Scratch.Add "search" (dict "title" .Title "tags" .Params.tags "contents" .Plain "permalink" .Permalink) -}}
+{{- end -}}
+{{- $.Scratch.Get "search" | jsonify -}}
\ No newline at end of file
-- 
cgit v1.2.3