✨ Add limit for generate index content, Resolved #101.
This commit is contained in:
@@ -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 }}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{{ $limit := .Site.Params.localSearch.limit | default 1000 }}
|
||||
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" | safeHTML }}
|
||||
<search>
|
||||
{{range where .Site.RegularPages "Kind" "page"}}
|
||||
@@ -12,7 +13,7 @@
|
||||
<tag>{{ . }}</tag>
|
||||
{{ end }}
|
||||
</tags>
|
||||
<content type="html"><![CDATA[{{ .Content | plainify }}]]></content>
|
||||
<content type="html"><![CDATA[ {{ if gt .WordCount $limit }} {{ .Plain | truncate $limit }} {{ else }} {{ .Plain }} {{ end }} ]]></content>
|
||||
</entry>
|
||||
{{ end }}
|
||||
</search>
|
||||
Reference in New Issue
Block a user