diff --git a/layouts/_default/list.search.json b/assets/search/config.json similarity index 52% rename from layouts/_default/list.search.json rename to assets/search/config.json index 9636348..6935793 100644 --- a/layouts/_default/list.search.json +++ b/assets/search/config.json @@ -1,5 +1,5 @@ -{{- $searchDataFile := printf "%s.searchdata.json" .Language.Lang -}} -{{- $searchData := resources.Get "search/searchdata.json" | resources.ExecuteAsTemplate $searchDataFile . | resources.Minify -}} +{{- $searchDataFile := printf "search/%s.data.json" .Language.Lang -}} +{{- $searchData := resources.Get "search/data.json" | resources.ExecuteAsTemplate $searchDataFile . | resources.Minify -}} { "dataFile": {{ $searchData.RelPermalink | jsonify }}, "indexConfig": {{ .Site.Params.GeekdocSearchConfig | jsonify }}, diff --git a/assets/search/searchdata.json b/assets/search/data.json similarity index 100% rename from assets/search/searchdata.json rename to assets/search/data.json diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 0c0ca12..22d8dc7 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -23,22 +23,9 @@ markup: taxonomies: tag: tags -outputFormats: - Search: - name: "Search" - mediaType: "application/json" - # generated file: . = feed.json - baseName: "searchconfig" - isPlainText: false - rel: "alternate" - isHTML: false - noUgly: true - permalinkable: false - outputs: home: - HTML - - SEARCH page: - HTML section: diff --git a/exampleSite/content/usage/configuration.md b/exampleSite/content/usage/configuration.md index 72724d3..c358a7b 100644 --- a/exampleSite/content/usage/configuration.md +++ b/exampleSite/content/usage/configuration.md @@ -32,19 +32,6 @@ enableRobotsTXT = true startLevel = 1 endLevel = 9 -[outputFormats.Search] -name = "Search" -mediaType = "application/json" -baseName = "searchconfig" -isPlainText = false -rel = "alternate" -isHTML = false -noUgly = true -permalinkable = false - -[outputs] -home = [ "HTML", "SEARCH" ] - [taxonomies] tag = "tags" @@ -83,8 +70,7 @@ home = [ "HTML", "SEARCH" ] # You can also specify this parameter per page in front matter. geekdocEditPath = "edit/main/exampleSite/content" - # (Optional, default true) Enables search function with flexsearch. To use the search you - # have to ensure `outputFormats` and `outputs` are properly configured as well (see below). + # (Optional, default true) Enables search function with flexsearch. # Index is built on the fly and might slow down your website. geekdocSearch = false @@ -162,23 +148,6 @@ markup: taxonomies: tag: tags -outputFormats: - Search: - name: "Search" - mediaType: "application/json" - # generated file: . = feed.json - baseName: "searchconfig" - isPlainText: false - rel: "alternate" - isHTML: false - noUgly: true - permalinkable: false - -outputs: - home: - - HTML - - SEARCH - params: # (Optional, default 6) Set how many table of contents levels to be showed on page. # Use false to hide ToC, note that 0 will default to 6 (https://gohugo.io/functions/default/) @@ -214,8 +183,7 @@ params: # You can also specify this parameter per page in front matter. geekdocEditPath: edit/main/exampleSite/content - # (Optional, default true) Enables search function with flexsearch. To use the search you - # have to ensure `outputFormats` and `outputs` are properly configured as well (see below). + # (Optional, default true) Enables search function with flexsearch. # Index is built on the fly and might slow down your website. geekdocSearch: false diff --git a/exampleSite/content/usage/getting-started.md b/exampleSite/content/usage/getting-started.md index b194ba7..c5c924f 100644 --- a/exampleSite/content/usage/getting-started.md +++ b/exampleSite/content/usage/getting-started.md @@ -69,19 +69,6 @@ To prepare your new site environment just a few steps are required: [taxonomies] tag = "tags" - - [outputFormats.Search] - name = "Search" - mediaType = "application/json" - baseName = "searchconfig" - isPlainText = false - rel = "alternate" - isHTML = false - noUgly = true - permalinkable = false - - [outputs] - home = [ "HTML", "SEARCH" ] ``` 5. Test your site. diff --git a/layouts/partials/foot.html b/layouts/partials/foot.html index d74d780..b919a7d 100644 --- a/layouts/partials/foot.html +++ b/layouts/partials/foot.html @@ -1,3 +1,5 @@ {{ if default true .Site.Params.GeekdocSearch }} - + + {{- $searchConfig := resources.Get "search/config.json" | resources.ExecuteAsTemplate "search/config.json" . | resources.Minify -}} + {{ end }} diff --git a/src/js/search.js b/src/js/search.js index a3e286c..d1eb6f5 100644 --- a/src/js/search.js +++ b/src/js/search.js @@ -24,7 +24,7 @@ document.addEventListener("DOMContentLoaded", function (event) { additionalProperties: false } - getJson("/searchconfig.json", function (searchConfig) { + getJson("/search/config.min.json", function (searchConfig) { const configValidate = ajv.compile(configSchema) const valid = configValidate(searchConfig)