about summary refs log tree commit diff stats
path: root/templates/page.templ
diff options
context:
space:
mode:
Diffstat (limited to 'templates/page.templ')
-rw-r--r--templates/page.templ24
1 files changed, 12 insertions, 12 deletions
diff --git a/templates/page.templ b/templates/page.templ
index 7869369..39dd263 100644
--- a/templates/page.templ
+++ b/templates/page.templ
@@ -2,9 +2,9 @@ package templates
 
 import (
 	"io/fs"
-	"net/url"
 
-	"website/internal/config"
+	"go.alanpearce.eu/website/internal/config"
+	"net/url"
 )
 
 var (
@@ -43,7 +43,7 @@ templ menuItem(item config.MenuItem) {
 	>{ item.Name }</a>
 }
 
-templ Page(site config.Config, page PageSettings) {
+templ Page(site *config.Config, page PageSettings) {
 	<!DOCTYPE html>
 	<html lang={ site.DefaultLanguage }>
 		<head>
@@ -74,7 +74,7 @@ templ Page(site config.Config, page PageSettings) {
 				<a href="https://git.alanpearce.eu/website/">Site source code</a> is
 				<a href="https://opensource.org/licenses/MIT">MIT</a>
 			</footer>
-			@counter(page.Path, page.Title)
+			@counter(site, page.Path, page.Title)
 			if site.InjectLiveReload {
 				<script defer>
 					new EventSource("/_/reload").onmessage = event => {
@@ -87,12 +87,12 @@ templ Page(site config.Config, page PageSettings) {
 	</html>
 }
 
-func mkURL(path string, title string) string {
-	u, err := url.Parse("https://alanpearce-eu.goatcounter.com/count")
-	if err != nil {
-		panic(err)
+func mkURL(original config.URL, path string, title string) string {
+	ou := *original.URL
+	u := config.URL{
+		URL: &ou,
 	}
-	q := u.Query()
+	q := url.Values{}
 	q.Add("p", path)
 	q.Add("t", title)
 	u.RawQuery = q.Encode()
@@ -100,10 +100,10 @@ func mkURL(path string, title string) string {
 	return u.String()
 }
 
-templ counter(path string, title string) {
-	<script data-goatcounter="https://alanpearce-eu.goatcounter.com/count" async src="https://gc.zgo.at/count.v4.js" crossorigin="anonymous" integrity="sha384-nRw6qfbWyJha9LhsOtSb2YJDyZdKvvCFh0fJYlkquSFjUxp9FVNugbfy8q1jdxI+"></script>
+templ counter(config *config.Config, path string, title string) {
+	<script data-goatcounter={ config.GoatCounter.String() } async src="https://stats.alanpearce.eu/count.v4.js" crossorigin="anonymous" integrity="sha384-nRw6qfbWyJha9LhsOtSb2YJDyZdKvvCFh0fJYlkquSFjUxp9FVNugbfy8q1jdxI+"></script>
 	<noscript>
-		<img src={ string(templ.URL(mkURL(path, title))) }/>
+		<img src={ string(templ.URL(mkURL(config.GoatCounter, path, title))) }/>
 	</noscript>
 }