feat: question tags
This commit is contained in:
parent
c87ce26da8
commit
69d96d646d
@ -29,6 +29,20 @@ body {
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.card-tags {
|
||||||
|
display: flex;
|
||||||
|
gap: .5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-tags .tag {
|
||||||
|
background-color: var(--meta-bg);
|
||||||
|
color: var(--tag-text-color);
|
||||||
|
padding: 0.5rem;
|
||||||
|
border-radius: 5px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
code {
|
code {
|
||||||
background-color: var(--code-bg);
|
background-color: var(--code-bg);
|
||||||
padding: 0.15rem;
|
padding: 0.15rem;
|
||||||
@ -123,7 +137,7 @@ img {
|
|||||||
.answers-header .sorting form {
|
.answers-header .sorting form {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: .5rem;
|
gap: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.answers-header select {
|
.answers-header select {
|
||||||
|
@ -98,6 +98,9 @@ func ViewQuestion(c *gin.Context) {
|
|||||||
|
|
||||||
questionPostLayout := doc.Find("div.post-layout").First()
|
questionPostLayout := doc.Find("div.post-layout").First()
|
||||||
|
|
||||||
|
questionTags := utils.GetPostTags(questionPostLayout)
|
||||||
|
newFilteredQuestion.Tags = questionTags
|
||||||
|
|
||||||
questionBodyParent := doc.Find("div.s-prose")
|
questionBodyParent := doc.Find("div.s-prose")
|
||||||
|
|
||||||
questionBodyParentHTML, err := questionBodyParent.Html()
|
questionBodyParentHTML, err := questionBodyParent.Html()
|
||||||
|
@ -10,4 +10,5 @@ type FilteredQuestion struct {
|
|||||||
AuthorURL string
|
AuthorURL string
|
||||||
ShortenedBody string
|
ShortenedBody string
|
||||||
Comments []FilteredComment
|
Comments []FilteredComment
|
||||||
|
Tags []string
|
||||||
}
|
}
|
||||||
|
13
src/utils/tags.go
Normal file
13
src/utils/tags.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/PuerkitoBio/goquery"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetPostTags(postLayout *goquery.Selection) []string {
|
||||||
|
var tags []string
|
||||||
|
postLayout.Find("a.post-tag").Each(func(i int, s *goquery.Selection) {
|
||||||
|
tags = append(tags, s.Text())
|
||||||
|
})
|
||||||
|
return tags
|
||||||
|
}
|
@ -38,6 +38,11 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">{{ .question.Body }}</div>
|
<div class="card-body">{{ .question.Body }}</div>
|
||||||
|
<div class="card-tags">
|
||||||
|
{{ range .question.Tags }}
|
||||||
|
<div class="tag">{{ . }}</div>
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
{{ if .question.Comments }} {{ template "comments.html"
|
{{ if .question.Comments }} {{ template "comments.html"
|
||||||
.question }} {{end}}
|
.question }} {{end}}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user