feat(search): add local search (#231)
* feat(search): add local search * docs: add docs for search
This commit is contained in:
@@ -209,6 +209,17 @@ Note that some of these parameters are explained in details in other sections of
|
||||
# {{< version 0.1.1 new small >}} which hash function used for SRI, when empty, no SRI is used
|
||||
# ("sha256", "sha384", "sha512", "md5")
|
||||
fingerprint = ""
|
||||
# {{< version 0.2.0 new small >}} Search
|
||||
[params.search]
|
||||
enable = true
|
||||
# type of search engine ("lunr", "algolia")
|
||||
type = "lunr"
|
||||
# index length of the content
|
||||
contentLength = 5000
|
||||
[params.search.algolia]
|
||||
index = ""
|
||||
appID = ""
|
||||
searchKey = ""
|
||||
# Header info
|
||||
[params.header]
|
||||
# desktop header mode ("fixed", "normal", "auto")
|
||||
@@ -460,6 +471,12 @@ Note that some of these parameters are explained in details in other sections of
|
||||
animateCSS = ''
|
||||
# {{< link "https://github.com/cferdinandi/smooth-scroll" "smooth-scroll" >}}@16.1.2
|
||||
smoothScrollJS = ''
|
||||
# {{< version 0.2.0 new small >}} {{< link "https://github.com/algolia/autocomplete.js" "autocomplete.js" >}}@0.37.1
|
||||
autocompleteJS = ''
|
||||
# {{< version 0.2.0 new small >}} {{< link "https://lunrjs.com/" "lunr.js" >}}@2.3.8
|
||||
lunrJS = ''
|
||||
# {{< version 0.2.0 new small >}} {{< link "https://github.com/algolia/algoliasearch-client-javascript" "algoliasearch" >}}@4.1.0
|
||||
algoliasearchJS = ''
|
||||
# {{< link "https://github.com/ellisonleao/sharer.js" "sharer" >}}@0.4.0
|
||||
sharerJS = ''
|
||||
# {{< link "https://github.com/aFarkas/lazysizes" "lazysizes" >}}@5.2.0
|
||||
@@ -480,17 +497,17 @@ Note that some of these parameters are explained in details in other sections of
|
||||
katexMhchemJS = ''
|
||||
# {{< link "https://github.com/knsv/mermaid" "mermaid" >}}@8.4.8
|
||||
mermaidJS = ''
|
||||
# {{< link "https://github.com/MoePlayer/APlayer" "aplayer" >}}@1.10.1
|
||||
aplayerCSS = ''
|
||||
aplayerJS = ''
|
||||
# {{< link "https://github.com/metowolf/MetingJS" "meting" >}}@2.0.1
|
||||
metingJS = ''
|
||||
# {{< link "https://echarts.apache.org/" "echarts" >}}@4.6.0
|
||||
echartsJS = ''
|
||||
echartsMacaronsJS = ''
|
||||
# {{< version 0.2.0 new small >}} {{< link "https://docs.mapbox.com/mapbox-gl-js" mapbox-gl >}}@1.8.1
|
||||
mapboxGLCSS = ''
|
||||
mapboxGLJS = ''
|
||||
# {{< link "https://github.com/MoePlayer/APlayer" "aplayer" >}}@1.10.1
|
||||
aplayerCSS = ''
|
||||
aplayerJS = ''
|
||||
# {{< link "https://github.com/metowolf/MetingJS" "meting" >}}@2.0.1
|
||||
metingJS = ''
|
||||
# {{< link "https://github.com/gitalk/gitalk" "gitalk" >}}@1.6.2
|
||||
gitalkCSS = ''
|
||||
gitalkJS = ''
|
||||
@@ -563,13 +580,24 @@ Note that some of these parameters are explained in details in other sections of
|
||||
|
||||
# Options to make hugo output files
|
||||
[outputs]
|
||||
home = ["HTML", "RSS"]
|
||||
# {{< version 0.2.0 changed small >}}
|
||||
home = ["HTML", "RSS", "JSON"]
|
||||
page = ["HTML", "MarkDown"]
|
||||
section = ["HTML", "RSS"]
|
||||
taxonomy = ["HTML", "RSS"]
|
||||
taxonomyTerm = ["HTML"]
|
||||
```
|
||||
|
||||
{{< admonition tip "Tips about CDN Configuration" >}}
|
||||
Full HTML tags or URLs are supported for CDN configuration:
|
||||
|
||||
```toml
|
||||
smoothScrollJS = '<script src="https://cdn.jsdelivr.net/npm/smooth-scroll@16.1.3/dist/smooth-scroll.min.js" integrity="sha256-vP+F+14A1ogChQs5Osd5LJl/ci9TbzjiZjjEbcqOXrY=" crossorigin="anonymous"></script>'
|
||||
# Or
|
||||
smoothScrollJS = 'https://cdn.jsdelivr.net/npm/smooth-scroll@16/dist/smooth-scroll.min.js'
|
||||
```
|
||||
{{< /admonition >}}
|
||||
|
||||

|
||||
|
||||
### 3.2 Favicons, Browserconfig, Manifest
|
||||
@@ -738,3 +766,50 @@ Translations strings are used for common default values used in the theme. Trans
|
||||
To override these values, create a new file in your local i18n folder `i18n/<languageCode>.toml` and inspire yourself from `themes/LoveIt/i18n/en.toml`.
|
||||
|
||||
By the way, as these translations could be used by other people, please take the time to propose a translation by [making a PR](https://github.com/dillonzq/LoveIt/pulls) to the theme!
|
||||
|
||||
## 5 Search
|
||||
|
||||
{{< version 0.2.0 >}}
|
||||
|
||||
Based on [Lunr.js](https://lunrjs.com/) or [algolia](https://www.algolia.com/), searching is supported in **LoveIt** theme.
|
||||
|
||||
### 5.1 Output Configuration
|
||||
|
||||
In order to generate `index.json` for searching, add `JSON` output file type to the `home` of the `outputs` part in your [site configuration](#site-configuration).
|
||||
|
||||
```toml
|
||||
[outputs]
|
||||
home = ["HTML", "RSS", "JSON"]
|
||||
```
|
||||
|
||||
### 5.2 Search Configuration
|
||||
|
||||
Based on `index.json` generated by Hugo, you could activate searching.
|
||||
|
||||
Here is the search configuration in your [site configuration](#site-configuration):
|
||||
|
||||
```toml
|
||||
[params.search]
|
||||
enable = true
|
||||
# type of search engine ("lunr", "algolia")
|
||||
type = "lunr"
|
||||
# index length of the content
|
||||
contentLength = 5000
|
||||
[params.search.algolia]
|
||||
index = ""
|
||||
appID = ""
|
||||
searchKey = ""
|
||||
```
|
||||
|
||||
{{< admonition note "How to choose the type of search engine?" >}}
|
||||
* `lunr`: simple, no need to synchronize `index.json`, no limit for `contentLength`,
|
||||
but high bandwidth and low performance (Especially for Chinese which needs a large segmentit library)
|
||||
* `algolia`: high performance and low bandwidth, but need to synchronize `index.json` and limit for `contentLength`
|
||||
{{< /admonition >}}
|
||||
|
||||
{{< admonition tip "Tips about algolia" >}}
|
||||
You need to upload `index.json` files to algolia to activate searching.
|
||||
You could upload the `index.json` files by browsers but a script may be a better choice.
|
||||
To be compatible with Hugo multilingual mode,
|
||||
you need to upload different `index.json` for each language to the different index of algolia, such as `zh-cn/index.json` or `fr/index.json`...
|
||||
{{< /admonition >}}
|
||||
|
||||
Reference in New Issue
Block a user