diff options
author | zzossig <zzossig@gmail.com> | 2020-02-06 13:04:23 +0300 |
---|---|---|
committer | zzossig <zzossig@gmail.com> | 2020-02-06 13:04:23 +0300 |
commit | 9d0c83fafd779bc3f8098c59664d8c93e6fed420 (patch) | |
tree | 42da2b804876bb8c9a1a9e9bfc084dc51ce59806 | |
parent | b9b1be1a78e88104ae151a965c0b553cb1f4366f (diff) |
search redesign
-rw-r--r-- | exampleSite/config/_default/config.toml | 12 | ||||
-rw-r--r-- | layouts/_default/list.searchindex.json | 7 | ||||
-rw-r--r-- | layouts/_default/single.searchindex.json | 7 | ||||
-rw-r--r-- | layouts/_default/terms.searchindex.json | 7 | ||||
-rw-r--r-- | layouts/index.json | 17 |
5 files changed, 38 insertions, 12 deletions
diff --git a/exampleSite/config/_default/config.toml b/exampleSite/config/_default/config.toml index 509898c..a34be73 100644 --- a/exampleSite/config/_default/config.toml +++ b/exampleSite/config/_default/config.toml @@ -33,7 +33,17 @@ disableKinds = ["taxonomyTerm"] startLevel = 2 [outputs] - home = ["HTML", "RSS", "JSON"] + page = ["HTML", "SearchIndex"] + home = ["HTML", "RSS", "SearchIndex"] + section = ["HTML", "RSS", "SearchIndex"] + taxonomy = ["HTML", "RSS", "SearchIndex"] + +[outputFormats] + [outputFormats.SearchIndex] + mediaType = "application/json" + baseName = "index" + isPlainText = true + notAlternative = true [taxonomies] tag = "tags" diff --git a/layouts/_default/list.searchindex.json b/layouts/_default/list.searchindex.json new file mode 100644 index 0000000..b29edc3 --- /dev/null +++ b/layouts/_default/list.searchindex.json @@ -0,0 +1,7 @@ +{{- $.Scratch.Add "searchindex" slice -}}
+{{- range $index, $element := (where .Site.Pages "Kind" "page") -}}
+ {{ with $element.Plain }}
+ {{- $.Scratch.Add "searchindex" (dict "id" $index "title" $element.Title "uri" $element.Permalink "tags" $element.Params.tags "section" $element.Section "content" $element.Plain "description" $element.Description) -}}
+ {{ end }}
+{{- end -}}
+{{- $.Scratch.Get "searchindex" | jsonify -}}
\ No newline at end of file diff --git a/layouts/_default/single.searchindex.json b/layouts/_default/single.searchindex.json new file mode 100644 index 0000000..b29edc3 --- /dev/null +++ b/layouts/_default/single.searchindex.json @@ -0,0 +1,7 @@ +{{- $.Scratch.Add "searchindex" slice -}}
+{{- range $index, $element := (where .Site.Pages "Kind" "page") -}}
+ {{ with $element.Plain }}
+ {{- $.Scratch.Add "searchindex" (dict "id" $index "title" $element.Title "uri" $element.Permalink "tags" $element.Params.tags "section" $element.Section "content" $element.Plain "description" $element.Description) -}}
+ {{ end }}
+{{- end -}}
+{{- $.Scratch.Get "searchindex" | jsonify -}}
\ No newline at end of file diff --git a/layouts/_default/terms.searchindex.json b/layouts/_default/terms.searchindex.json new file mode 100644 index 0000000..b29edc3 --- /dev/null +++ b/layouts/_default/terms.searchindex.json @@ -0,0 +1,7 @@ +{{- $.Scratch.Add "searchindex" slice -}}
+{{- range $index, $element := (where .Site.Pages "Kind" "page") -}}
+ {{ with $element.Plain }}
+ {{- $.Scratch.Add "searchindex" (dict "id" $index "title" $element.Title "uri" $element.Permalink "tags" $element.Params.tags "section" $element.Section "content" $element.Plain "description" $element.Description) -}}
+ {{ end }}
+{{- end -}}
+{{- $.Scratch.Get "searchindex" | jsonify -}}
\ No newline at end of file diff --git a/layouts/index.json b/layouts/index.json index 367f3b3..0a96038 100644 --- a/layouts/index.json +++ b/layouts/index.json @@ -1,12 +1,7 @@ -[{{ range $index, $page := .Site.Pages }} -{{- if ne $page.Type "json" -}} -{{- if and $index (gt $index 0) -}},{{- end }} -{ - "uri": "{{ $page.Permalink }}", - "title": "{{ htmlEscape $page.Title}}", - "tags": [{{ range $tindex, $tag := $page.Params.tags }}{{ if $tindex }}, {{ end }}"{{ $tag| htmlEscape }}"{{ end }}], - "description": "{{ htmlEscape .Description}}", - "content": {{$page.Plain | jsonify}} -} +{{- $.Scratch.Add "searchindex" slice -}} +{{- range $index, $element := (where .Site.Pages "Kind" "page") -}} + {{ with $element.Plain }} + {{- $.Scratch.Add "searchindex" (dict "id" $index "title" $element.Title "uri" $element.Permalink "tags" $element.Params.tags "section" $element.Section "content" $element.Plain "description" $element.Description) -}} + {{ end }} {{- end -}} -{{- end -}}]
\ No newline at end of file +{{- $.Scratch.Get "searchindex" | jsonify -}}
\ No newline at end of file |