Add limit for generate index content, Resolved #101.

This commit is contained in:
elkan1788
2023-06-28 16:33:02 +08:00
parent b4c5e79c1b
commit 35fff3e0cc
5 changed files with 16 additions and 6 deletions

View File

@@ -1,3 +1,4 @@
{{ $limit := .Site.Params.algoliaSearch.limit | default 1000 }}
[
{{ range $index, $entry := where .Site.RegularPages "Kind" "page" }}
{{ if $index }}, {{ end }}
@@ -5,7 +6,11 @@
"objectID": "{{ .Date.Unix }}",
"permalink": "{{ .Permalink | relURL }}",
"title": {{ .Title | jsonify }},
{{ if gt .WordCount $limit }}
"content": {{ .Plain | truncate $limit | jsonify | safeJS }},
{{ else }}
"content": {{ .Plain | jsonify | safeJS }},
{{ end }}
"date": {{ .Date.Format $.Site.Params.timeFormat | jsonify }},
"updated": {{ .Lastmod.Format $.Site.Params.timeFormat | jsonify }}
}