Fix: blank blog/categories links in search results

This commit is contained in:
hyzen
2026-07-26 22:41:13 +05:30
parent 17c88b8991
commit adc31a948a
4 changed files with 12 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@@ -45,6 +45,7 @@
}
function sectionLabel(section) {
if (section === 'blog-category') return 'Category';
if (section === 'blog') return 'Blog';
if (section === 'services') return 'Service';
return section;

View File

@@ -21,10 +21,13 @@ Consumed client-side by /js/search.js.
{{- $excluded = true -}}
{{- end -}}
{{- end -}}
{{- if not $excluded -}}
{{- if and (not $excluded) (ne $permalink "") -}}
{{- $pages = $pages | append . -}}
{{- end -}}
{{- end -}}
{{- range site.Taxonomies.categories.Alphabetical -}}
{{- $pages = $pages | append .Page -}}
{{- end -}}
[
{{- range $i, $p := $pages -}}
{{- if $i }},{{ end -}}
@@ -34,10 +37,14 @@ Consumed client-side by /js/search.js.
{{- $text := $clean | plainify | htmlUnescape -}}
{{- $text = replaceRE `\s+` " " $text -}}
{{- $text = strings.TrimSpace $text -}}
{{- $section := cond (eq $p.Section "") "home" $p.Section -}}
{{- if eq $p.Kind "term" -}}
{{- $section = "blog-category" -}}
{{- end -}}
{
"title": {{ $p.Title | jsonify }},
"url": {{ $p.RelPermalink | jsonify }},
"section": {{ (cond (eq $p.Section "") "home" $p.Section) | jsonify }},
"section": {{ $section | jsonify }},
"content": {{ $text | jsonify }}
}
{{- end -}}

View File

@@ -45,6 +45,7 @@
}
function sectionLabel(section) {
if (section === 'blog-category') return 'Category';
if (section === 'blog') return 'Blog';
if (section === 'services') return 'Service';
return section;