Skip to content

Commit

Permalink
perf: use hugo.IsMultihost instead of custom function
Browse files Browse the repository at this point in the history
Closes #225
  • Loading branch information
razonyang committed May 26, 2024
1 parent 83cca6f commit 272caa9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 17 deletions.
2 changes: 1 addition & 1 deletion hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ notAlternative = true
[module]
[module.hugoVersion]
extended = true
min = "0.121.0"
min = "0.124.0"

[[module.imports]]
path = "github.com/hugomods/i18n-js"
Expand Down
3 changes: 1 addition & 2 deletions layouts/partials/search/assets/js-resource.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{- $defaultLang := .Sites.First.Language.Lang }}
{{- $multihost := partialCached "search/functions/is-multihost" . }}
{{- $langs := newScratch }}
{{- range .Site.Languages }}
{{- $langs.Set .Lang (dict "lang" .Lang "name" .LanguageName) }}
Expand Down Expand Up @@ -82,7 +81,7 @@
{{- $site := . }}
{{- with .Home.OutputFormats.Get "SearchIndex" }}
{{- $hash := partialCached "search/functions/search-index-hash" $site $site }}
{{- $indexURL := printf "%s?v=%s" (cond $multihost .Permalink .RelPermalink) $hash }}
{{- $indexURL := printf "%s?v=%s" (cond hugo.IsMultihost .Permalink .RelPermalink) $hash }}
{{- $indices = $indices | append $indexURL }}
{{- end }}
{{- end }}
Expand Down
11 changes: 0 additions & 11 deletions layouts/partials/search/functions/is-multihost.html

This file was deleted.

5 changes: 2 additions & 3 deletions layouts/partials/search/index.json.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{- $items := slice -}}
{{- $multihost := partialCached "search/functions/is-multihost" . }}
{{- $indexContent := default false site.Params.search.index_content -}}
{{- $years := true }}
{{- $pages := partial "search/functions/pages" . -}}
Expand All @@ -13,7 +12,7 @@
{{- end }}
{{- $item.Set "kind" .Kind -}}
{{- $item.Set "lang" .Language.Lang -}}
{{- $item.Set "url" (cond $multihost .Permalink .RelPermalink) -}}
{{- $item.Set "url" (cond hugo.IsMultihost .Permalink .RelPermalink) -}}
{{- $item.Set "date" .Date.Unix -}}
{{- if $years -}}
{{- $item.Set "year" (.Date.Format "2006") -}}
Expand All @@ -22,7 +21,7 @@
{{- if or $page.Params.images ($page.Resources.GetMatch "{*feature*,*cover*,*thumbnail*}") -}}
{{- with partial "_funcs/get-page-images" $page -}}
{{- $img := index . 0 -}}
{{- $item.Set "img" (cond $multihost $img.Permalink $img.RelPermalink) -}}
{{- $item.Set "img" (cond hugo.IsMultihost $img.Permalink $img.RelPermalink) -}}
{{- end -}}
{{- end -}}
{{- $item.Set "headings" (partialCached "search/functions/parse-headings" . .) -}}
Expand Down

0 comments on commit 272caa9

Please sign in to comment.