Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#gohugo search index with "some" stop words removed
{{- $.Scratch.Add "index" slice -}}
{{$index := where .Site.RegularPages ".Section" "not in" (slice "links" "internal") }}
{{- range $index -}}
{{ with .Params.images }}
{{ $.Scratch.Set "image" (index . 0)}}
{{ else }}
{{ $.Scratch.Set "image" "/uploads/logo.jpg"}}
{{ end }}
{{ $image := printf "%s%s" (replace ($.Scratch.Get "image") "/uploads" .Site.Params.image_url) "?fit=crop&h=201&w=358" }}
{{- $content_filtered := replaceRE "(?m)(?i)(?s:\\ba\\b|\\band\\b|\\barchival\\b|\\bagain\\b|\\bin\\b|\\bto\\b|\\bis\\b|\\bno\\b|\\bor\\b|\\bthis\\b|\\bwell\\b|\\byes\\b|\\bthe\\b|\\bthere\\b|\\bthese\\b|\\bthen\\b)" "" (delimit .PlainWords " ") -}}
{{- $.Scratch.Add "index" (dict "Section" .Section "objectID" (md5 .File.Path) "date" (.Date.Format "January 2, 2006") "sort_date" .Date.Unix "title" .Title "ref" .RelPermalink "tags" .Params.tags "content" $content_filtered "producer" .Params.producers "image" $image) -}}
{{- end -}}
{{- $.Scratch.Get "index" | jsonify -}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment