converts tags to topics
This commit is contained in:
@ -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") -}}
|
||||
|
Reference in New Issue
Block a user