feat: question tags
This commit is contained in:
@ -98,6 +98,9 @@ func ViewQuestion(c *gin.Context) {
|
||||
|
||||
questionPostLayout := doc.Find("div.post-layout").First()
|
||||
|
||||
questionTags := utils.GetPostTags(questionPostLayout)
|
||||
newFilteredQuestion.Tags = questionTags
|
||||
|
||||
questionBodyParent := doc.Find("div.s-prose")
|
||||
|
||||
questionBodyParentHTML, err := questionBodyParent.Html()
|
||||
|
@ -10,4 +10,5 @@ type FilteredQuestion struct {
|
||||
AuthorURL string
|
||||
ShortenedBody string
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user