diff options
author | Dillon <dillonzq@outlook.com> | 2020-04-28 21:34:28 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-28 21:34:28 +0300 |
commit | 16a4e94117f118a358d1c0184db48e70a0aa63a9 (patch) | |
tree | a99069c4308bf229b87745c1dfe91661998b8b82 /exampleSite/content | |
parent | aa5f490aae97097c4b5984ef4e753d160d89d103 (diff) |
feat(search): add more params for search and improve search index (#279)
Diffstat (limited to 'exampleSite/content')
3 files changed, 56 insertions, 14 deletions
diff --git a/exampleSite/content/posts/theme-documentation-basics.en.md b/exampleSite/content/posts/theme-documentation-basics.en.md index 06c9abc..0584e26 100644 --- a/exampleSite/content/posts/theme-documentation-basics.en.md +++ b/exampleSite/content/posts/theme-documentation-basics.en.md @@ -221,10 +221,14 @@ Please open the code block below to view the complete sample configuration :(far enable = true # type of search engine ("lunr", "algolia") type = "lunr" - # index length of the content + # max index length of the chunked content contentLength = 5000 # placeholder of the search bar placeholder = "" + # {{< version 0.2.1 >}} max number of results length + maxResultLength = 10 + # {{< version 0.2.1 >}} HTML tag name of the highlight part in results + highlightTag = "em" [params.search.algolia] index = "" appID = "" @@ -955,25 +959,35 @@ Here is the search configuration in your [site configuration](#site-configuratio enable = true # type of search engine ("lunr", "algolia") type = "lunr" - # index length of the content + # max index length of the chunked content contentLength = 5000 + # placeholder of the search bar + placeholder = "" + # {{< version 0.2.1 >}} max number of results length + maxResultLength = 10 + # {{< version 0.2.1 >}} HTML tag name of the highlight part in results + highlightTag = "em" [params.search.algolia] index = "" appID = "" searchKey = "" ``` -{{< admonition note "How to choose the type of search engine?" >}} +{{< admonition note "How to choose search engine?" >}} The following is a comparison of two search engines: * `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` + +{{< version 0.2.1 >}} The content of the post is separated by `h2` HTML tag to improve query performance and basically implement full-text search. +`contentLength` is used to limit the max index length of the part starting with `h2` HTML tag. {{< /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. +You could upload the `index.json` files by browsers but a CLI tool may be better. +[Algolia Atomic](https://github.com/chrisdmacrae/atomic-algolia) is a good 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 >}} diff --git a/exampleSite/content/posts/theme-documentation-basics.fr.md b/exampleSite/content/posts/theme-documentation-basics.fr.md index 90a38f2..c42ec42 100644 --- a/exampleSite/content/posts/theme-documentation-basics.fr.md +++ b/exampleSite/content/posts/theme-documentation-basics.fr.md @@ -226,10 +226,14 @@ Please open the code block below to view the complete sample configuration :(far enable = true # type of search engine ("lunr", "algolia") type = "lunr" - # index length of the content + # max index length of the chunked content contentLength = 5000 # placeholder of the search bar placeholder = "" + # {{< version 0.2.1 >}} max number of results length + maxResultLength = 10 + # {{< version 0.2.1 >}} HTML tag name of the highlight part in results + highlightTag = "em" [params.search.algolia] index = "" appID = "" @@ -960,25 +964,35 @@ Here is the search configuration in your [site configuration](#site-configuratio enable = true # type of search engine ("lunr", "algolia") type = "lunr" - # index length of the content + # max index length of the chunked content contentLength = 5000 + # placeholder of the search bar + placeholder = "" + # {{< version 0.2.1 >}} max number of results length + maxResultLength = 10 + # {{< version 0.2.1 >}} HTML tag name of the highlight part in results + highlightTag = "em" [params.search.algolia] index = "" appID = "" searchKey = "" ``` -{{< admonition note "How to choose the type of search engine?" >}} +{{< admonition note "How to choose search engine?" >}} The following is a comparison of two search engines: * `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` + +{{< version 0.2.1 >}} The content of the post is separated by `h2` HTML tag to improve query performance and basically implement full-text search. +`contentLength` is used to limit the max index length of the part starting with `h2` HTML tag. {{< /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. +You could upload the `index.json` files by browsers but a CLI tool may be better. +[Algolia Atomic](https://github.com/chrisdmacrae/atomic-algolia) is a good 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 >}} diff --git a/exampleSite/content/posts/theme-documentation-basics.zh-cn.md b/exampleSite/content/posts/theme-documentation-basics.zh-cn.md index e744bae..fdaf744 100644 --- a/exampleSite/content/posts/theme-documentation-basics.zh-cn.md +++ b/exampleSite/content/posts/theme-documentation-basics.zh-cn.md @@ -224,10 +224,14 @@ hugo enable = true # 搜索引擎的类型 ("lunr", "algolia") type = "lunr" - # 文章内容索引长度 + # 文章内容最长索引长度 contentLength = 5000 # 搜索框的占位提示语 placeholder = "" + # 最大结果数目 + maxResultLength = 10 + # 搜索结果中高亮部分的 HTML 标签 + highlightTag = "em" [params.search.algolia] index = "" appID = "" @@ -938,7 +942,7 @@ defaultContentLanguage = "zh-cn" {{< version 0.2.0 >}} -基于 [Lunr.js](https://lunrjs.com/) 或 [algolia](https://www.algolia.com/), **LoveIt** 主支持搜索功能. +基于 [Lunr.js](https://lunrjs.com/) 或 [algolia](https://www.algolia.com/), **LoveIt** 主题支持搜索功能. ### 5.1 输出配置 @@ -958,24 +962,34 @@ defaultContentLanguage = "zh-cn" ```toml [params.search] enable = true - # type of search engine ("lunr", "algolia") + # 搜索引擎的类型 ("lunr", "algolia") type = "lunr" - # index length of the content + # 文章内容最长索引长度 contentLength = 5000 + # 搜索框的占位提示语 + placeholder = "" + # 最大结果数目 + maxResultLength = 10 + # 搜索结果中高亮部分的 HTML 标签 + highlightTag = "em" [params.search.algolia] index = "" appID = "" searchKey = "" ``` -{{< admonition note "怎样选择搜索引擎的类型?" >}} +{{< admonition note "怎样选择搜索引擎?" >}} 以下是两种搜索引擎的对比: * `lunr`: 简单, 无需同步 `index.json`, 没有 `contentLength` 的限制, 但占用带宽大且性能低 (特别是中文需要一个较大的分词依赖库) * `algolia`: 高性能并且占用带宽低, 但需要同步 `index.json` 且有 `contentLength` 的限制 + +{{< version 0.2.1 >}} 文章内容被 `h2` HTML 标签切分来提供查询效果并且基本实现全文搜索. +`contentLength` 用来限制 `h2` HTML 标签开头的内容部分的最大长度. {{< /admonition >}} {{< admonition tip "关于 algolia 的使用技巧" >}} -你需要上传 `index.json` 到 algolia 来激活搜索功能. 你可以使用浏览器来上传 `index.json` 文件但是一个自动化的脚本可能是更好的选择. +你需要上传 `index.json` 到 algolia 来激活搜索功能. 你可以使用浏览器来上传 `index.json` 文件但是一个自动化的脚本可能效果更好. +[Algolia Atomic](https://github.com/chrisdmacrae/atomic-algolia) 是一个不错的选择. 为了兼容 Hugo 的多语言模式, 你需要上传不同语言的 `index.json` 文件到对应的 algolia index, 例如 `zh-cn/index.json` 或 `fr/index.json`... {{< /admonition >}} |