From 36963a2839b33121de235c5e16743e508a52b9ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20Herg=C3=A8s?= Date: Sun, 7 Sep 2025 15:32:45 +0200 Subject: feat(now): modify how links are handled --- data.go | 1 + index.ts | 9 --------- main.go | 4 ++-- scss/tag.scss | 1 - templates/page/now.gohtml | 6 ++++-- 5 files changed, 7 insertions(+), 14 deletions(-) diff --git a/data.go b/data.go index fccaec3..e250d78 100644 --- a/data.go +++ b/data.go @@ -55,6 +55,7 @@ type Tag struct { Name string `json:"name" toml:"name"` Description string `json:"description" toml:"description"` Link string `json:"link" toml:"link"` + LinkName string `json:"link_name" toml:"link_name"` } type Color struct { diff --git a/index.ts b/index.ts index e48401f..68b6f19 100644 --- a/index.ts +++ b/index.ts @@ -1,13 +1,4 @@ function setupEvents() { - document.querySelectorAll(".tag")?.forEach(t => { - t.addEventListener("click", _ => { - const link = t.getAttribute("data-href") - if (link === null || link === "") return - if (!link.startsWith(window.location.origin) && link.startsWith("https://")) window.open(link) - else changePage(link) - }) - }) - document.querySelectorAll("a")?.forEach(a => { a.addEventListener("click", e => { if (!a.href.startsWith(window.location.origin)) return diff --git a/main.go b/main.go index 22ff486..7f967ff 100644 --- a/main.go +++ b/main.go @@ -186,8 +186,8 @@ func generateConfigFile(isToml bool) { Pronouns: "any", Image: "pfp.webp", Tags: []*Tag{ - {"Hello", "World", ""}, - {"I am", "a tag", ""}, + {"Hello", "World", "", ""}, + {"I am", "a tag", "", ""}, }, }, Color: &Color{ diff --git a/scss/tag.scss b/scss/tag.scss index 10fc161..a604380 100644 --- a/scss/tag.scss +++ b/scss/tag.scss @@ -22,7 +22,6 @@ } .tag { - cursor: pointer; padding: 0.5rem; margin: -0.5rem; border-radius: 8px; diff --git a/templates/page/now.gohtml b/templates/page/now.gohtml index 776e87a..6af668e 100644 --- a/templates/page/now.gohtml +++ b/templates/page/now.gohtml @@ -8,10 +8,12 @@
{{ range $tag := .Person.Tags }} -
+

{{ .Name }}

{{ .Description }}

-

Hello

+ {{ if and (ne .Link "") (ne .LinkName "") }} +

{{ .LinkName }}

+ {{ end }}
{{ end }}
-- cgit v1.2.3