feat(tag): link
This commit is contained in:
parent
2621bc5978
commit
44173f34c2
4 changed files with 10 additions and 3 deletions
1
data.go
1
data.go
|
@ -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 {
|
||||||
|
|
4
index.ts
4
index.ts
|
@ -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)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -155,12 +155,16 @@
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"link": {
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": [
|
"required": [
|
||||||
"name",
|
"name",
|
||||||
"description"
|
"description",
|
||||||
|
"link"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue