diff --git a/layouts/partials/replace-content-with-keywords-links.html b/layouts/partials/replace-content-with-keywords-links.html new file mode 100644 index 0000000..c7c88ac --- /dev/null +++ b/layouts/partials/replace-content-with-keywords-links.html @@ -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 . "." }} +{{ end }} +{{ end }} + +{{ $Content | safeHTML }} \ No newline at end of file diff --git a/static/csv/keywords-links.csv b/static/csv/keywords-links.csv new file mode 100644 index 0000000..e69de29