diff options
| author | Anhgelus Morhtuuzh <anhgelus.morhtuuzh@proton.me> | 2024-11-14 15:35:21 +0100 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <anhgelus.morhtuuzh@proton.me> | 2024-11-14 15:35:21 +0100 |
| commit | 44173f34c293d011019b84be7095039eac977c5b (patch) | |
| tree | 7f6259d439c0eb6b25e2e73c24fb5dd7a63edccf | |
| parent | 2621bc5978fc7f6f24d2f0ba91715c01c62b43a9 (diff) | |
feat(tag): link
| -rw-r--r-- | data.go | 1 | ||||
| -rw-r--r-- | index.ts | 4 | ||||
| -rw-r--r-- | schema.json | 6 | ||||
| -rw-r--r-- | templates/page/tags.gohtml | 2 |
4 files changed, 10 insertions, 3 deletions
@@ -25,6 +25,7 @@ type Person struct { type Tag struct { Name string `json:"name"` Description string `json:"description"` + Link string `json:"link"` } type Color struct { @@ -1,7 +1,9 @@ function setupEvents() { document.querySelectorAll<HTMLElement>(".tag")?.forEach(t => { t.addEventListener("click", _ => { - // t.classList.toggle("active") + const link = t.getAttribute("data-href") + if (link === null || link === "") return + window.open(link) }) }) diff --git a/schema.json b/schema.json index d73f3db..2678ecf 100644 --- a/schema.json +++ b/schema.json @@ -155,12 +155,16 @@ }, "name": { "type": "string" + }, + "link": { + "type": "string" } }, "additionalProperties": false, "required": [ "name", - "description" + "description", + "link" ] } } diff --git a/templates/page/tags.gohtml b/templates/page/tags.gohtml index 4713ff4..8a81810 100644 --- a/templates/page/tags.gohtml +++ b/templates/page/tags.gohtml @@ -3,7 +3,7 @@ <h2>Tags</h2> <div class="tags" style="{{ .Color.GetTagColor }}"> {{ range $tag := .Person.Tags }} - <div class="tag"> + <div class="tag" data-href="{{ .Link }}" title="{{ .Link }}"> <h4>{{ .Name }}</h4> <p>{{ .Description }}</p> </div> |
