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

@ -17,7 +17,7 @@
<p class="text-gray-800 italic">{{ $page.Params.location }}</p>
{{ end }}
<p class="max-w-prose">{{ $page.Params.summary }}</p>
{{ partial "tags.html" $page }}
{{ partial "topics.html" $page }}
</div>
</li>
{{ end }}

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") -}}

View File

@ -1,7 +1,7 @@
{{- if .Params.tags }}
{{- if .Params.topics }}
<div class="flex flex-wrap gap-2 my-2 text-xs font-iosevka">
{{- range .Params.tags }}
<a href="{{ "tags/" | relURL }}{{ . | urlize }}"
{{- range .Params.topics }}
<a href="{{ "topics/" | relURL }}{{ . | urlize }}"
class="px-3 py-1 border border-green-100 hover:bg-green-300 text-green-900 rounded no-underline">
{{ . }}
</a>