converts tags to topics

This commit is contained in:
Drew
2025-04-07 15:41:29 -06:00
parent 75114cdbbe
commit 67866adb1a
15 changed files with 27 additions and 27 deletions

View File

@ -1,15 +1,15 @@
{{- $tags := .tags -}}
{{- $topics := .topics -}}
{{- $limit := default 3 .limit -}}
{{- $currentPath := .page.RelPermalink -}}
{{- $related := where (where site.RegularPages "Type" "articles") "RelPermalink" "!=" $currentPath -}}
{{- $matchingArticles := slice -}}
{{/* First try to find articles with matching tags */}}
{{/* First try to find articles with matching topics */}}
{{- range $related -}}
{{- $matches := 0 -}}
{{- range .Params.tags -}}
{{- if in $tags . -}}
{{- range .Params.topics -}}
{{- if in $topics . -}}
{{- $matches = add $matches 1 -}}
{{- end -}}
{{- end -}}
@ -18,7 +18,7 @@
{{- end -}}
{{- end -}}
{{/* If we found matching articles, sort by number of matching tags */}}
{{/* If we found matching articles, sort by number of matching topics */}}
{{- $finalArticles := slice -}}
{{- if gt (len $matchingArticles) 0 -}}
{{- $finalArticles = first $limit (sort $matchingArticles "matches" "desc") -}}