draft for #102, to be done...

This commit is contained in:
Jason TIAN 2023-01-15 13:03:21 +08:00
parent 55a9f019ae
commit 0b565afaf9
2 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,26 @@
{{/* this is used to replace the keywords in content with links
reference:
- https://discourse.gohugo.io/t/replace-function-when-applied-to-content-displays-html-tags-instead-of-rendering-them/37717
- https://gohugo.io/templates/data-templates/
- https://github.com/gohugoio/hugo/issues/1150
*/}}
{{ $Content := .Content }}
{{/* to be fixed... */}}
{{ $url := "static/csv/keywords-links.csv" }}.
{{ $sep := "," }}
{{ range $i, $r := getCSV $sep $url }}
{{ index $r 0 }}
{{ index $r 1 }}
{{ end }}
{{ range $topics }}
{{- if (strings.Contains $Content .) -}}
{{ $Content = replace $Content . "<a href='$Permalink'>.</a>" }}
{{ end }}
{{ end }}
{{ $Content | safeHTML }}

View File