Skip to content

Commit

Permalink
feat: generate the hash for search indices
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed May 13, 2023
1 parent bd75d1a commit ab0d829
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion layouts/_default/index.searchindex.json
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{{- partial "search/index.json" . -}}
{{- $ctx := dict "Site" .Site }}
{{- partialCached "search/index.json" $ctx $ctx -}}
6 changes: 3 additions & 3 deletions layouts/partials/search/assets/js-resource.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@
{{/* Index files URL. */}}
{{- $indices := slice }}
{{- range .Sites }}
{{- $site := . }}
{{- with .Home.OutputFormats.Get "SearchIndex" }}
{{- $indexURL := .RelPermalink }}
{{/* TODO */}}
{{- $indexURL = printf "%s?v=%s" $indexURL "HASH" }}
{{- $idxCtx := dict "Site" $site "Index" . }}
{{- $indexURL := partialCached "search/functions/search-index-url" $idxCtx $idxCtx }}
{{- $indices = $indices | append $indexURL }}
{{- end }}
{{- end }}
Expand Down
3 changes: 3 additions & 0 deletions layouts/partials/search/functions/search-index-url.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- $ctx := dict "Site" .Site }}
{{- $hash := partialCached "search/index.json" $ctx $ctx | md5 }}
{{- return (printf "%s?v=%s" .Index.RelPermalink $hash) }}

0 comments on commit ab0d829

Please sign in to comment.