feat(search): improve search index by rm line number in code block (#294))
This commit is contained in:
2
assets/js/theme.min.js
vendored
2
assets/js/theme.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -13,7 +13,10 @@
|
||||
{{- $index = $index | append (dict "content" . "objectID" $uri | merge $meta) -}}
|
||||
{{- end -}}
|
||||
{{- $params := .Params | merge $.Site.Params.page -}}
|
||||
{{/* Extended Markdown syntax */}}
|
||||
{{- $content := dict "content" .Content "ruby" $params.ruby "fraction" $params.fraction "fontawesome" $params.fontawesome | partial "function/content.html" -}}
|
||||
{{/* Remove line number for code */}}
|
||||
{{- $content = $content | replaceRE `<span class="lnt?"> *\d*\n?</span>` "" -}}
|
||||
{{- range $i, $contenti := split $content "<h2 id=" -}}
|
||||
{{- if gt $i 0 -}}
|
||||
{{- $contenti = printf "<h2 id=%s" $contenti -}}
|
||||
@@ -22,6 +25,7 @@
|
||||
{{- if gt $j 0 -}}
|
||||
{{- $contentj = printf "<h3 id=%s" $contentj -}}
|
||||
{{- end -}}
|
||||
{{/* Plainify, unescape and remove (\n, \t) */}}
|
||||
{{- $contentj = $contentj | plainify | htmlUnescape | replaceRE `[\n\t ]+` " " -}}
|
||||
{{- if gt $.Site.Params.search.contentLength 0 -}}
|
||||
{{- $contentj = substr $contentj 0 $.Site.Params.search.contentLength -}}
|
||||
|
||||
@@ -238,7 +238,7 @@ class Theme {
|
||||
this._algoliaIndex
|
||||
.search(query, {
|
||||
offset: 0,
|
||||
length: searchConfig.maxResultLength * 10,
|
||||
length: searchConfig.maxResultLength * 5,
|
||||
attributesToHighlight: ['title'],
|
||||
attributesToSnippet: ['content:30'],
|
||||
highlightPreTag: `<${searchConfig.highlightTag}>`,
|
||||
@@ -637,7 +637,6 @@ class Theme {
|
||||
this._resizeTimeout = null;
|
||||
for (let event of this.resizeEventSet) event();
|
||||
this.initToc();
|
||||
this.initSmoothScroll();
|
||||
this.initMermaid();
|
||||
this.initSearch();
|
||||
}, 100);
|
||||
|
||||
Reference in New Issue
Block a user