feat(tag): link

This commit is contained in:
Anhgelus Morhtuuzh 2024-11-14 15:35:21 +01:00
parent 2621bc5978
commit 44173f34c2
No known key found for this signature in database
GPG key ID: CAD341EFA92DDDE5
4 changed files with 10 additions and 3 deletions

View file

@ -25,6 +25,7 @@ type Person struct {
type Tag struct { type Tag struct {
Name string `json:"name"` Name string `json:"name"`
Description string `json:"description"` Description string `json:"description"`
Link string `json:"link"`
} }
type Color struct { type Color struct {

View file

@ -1,7 +1,9 @@
function setupEvents() { function setupEvents() {
document.querySelectorAll<HTMLElement>(".tag")?.forEach(t => { document.querySelectorAll<HTMLElement>(".tag")?.forEach(t => {
t.addEventListener("click", _ => { t.addEventListener("click", _ => {
// t.classList.toggle("active") const link = t.getAttribute("data-href")
if (link === null || link === "") return
window.open(link)
}) })
}) })

View file

@ -155,12 +155,16 @@
}, },
"name": { "name": {
"type": "string" "type": "string"
},
"link": {
"type": "string"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"required": [ "required": [
"name", "name",
"description" "description",
"link"
] ]
} }
} }

View file

@ -3,7 +3,7 @@
<h2>Tags</h2> <h2>Tags</h2>
<div class="tags" style="{{ .Color.GetTagColor }}"> <div class="tags" style="{{ .Color.GetTagColor }}">
{{ range $tag := .Person.Tags }} {{ range $tag := .Person.Tags }}
<div class="tag"> <div class="tag" data-href="{{ .Link }}" title="{{ .Link }}">
<h4>{{ .Name }}</h4> <h4>{{ .Name }}</h4>
<p>{{ .Description }}</p> <p>{{ .Description }}</p>
</div> </div>