Files
Personal-Website/themes/maik-blog/layouts/partials/page_views.html
T
2025-01-03 22:04:15 +01:00

17 lines
568 B
HTML

{{- if .Site.Params.goatCounter }}
<span id="{{ .File.UniqueID }}" title="{{ i18n "post.pageViews" }}">{{ i18n "post.unknownViews" }}</span>
<script>
let url =
"https://{{ .Site.Params.goatCounter }}/counter/" +
encodeURIComponent({{ .RelPermalink }}.replace(/(\/)?$/, "")) +
".json";
fetch(url)
.then(res => res.json())
.then(data => data.count)
.then(count => {
document.getElementById("{{ .File.UniqueID }}").innerText = count + " " + {{ i18n "post.pageViews" }};
});
</script>
{{- end}}