feat: get answers and iterate over them
This commit is contained in:
parent
b7345d39a0
commit
f1d22a713f
10
main.go
10
main.go
@ -96,12 +96,22 @@ func main() {
|
||||
}
|
||||
})
|
||||
|
||||
answers := []template.HTML{}
|
||||
doc.Find("div.answer").Each(func(i int, s *goquery.Selection) {
|
||||
postLayout := s.Find("div.post-layout")
|
||||
answerCell := postLayout.Find("div.answercell")
|
||||
answerBody := answerCell.Find("div.s-prose")
|
||||
answerBodyHTML, _ := answerBody.Html()
|
||||
answers = append(answers, template.HTML(answerBodyHTML))
|
||||
})
|
||||
|
||||
c.HTML(200, "question.html", gin.H{
|
||||
"title": questionText,
|
||||
"body": template.HTML(questionBodyParentHTML),
|
||||
"timestamp": questionTimestamp,
|
||||
"author": questionAuthor,
|
||||
"authorURL": questionAuthorURL,
|
||||
"answers": answers,
|
||||
})
|
||||
|
||||
})
|
||||
|
@ -30,6 +30,11 @@ body {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.parent {
|
||||
max-width: 90%;
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
code {
|
||||
background-color: var(--code-bg);
|
||||
padding: .15rem;
|
||||
@ -54,4 +59,12 @@ pre {
|
||||
|
||||
a {
|
||||
color: #92adff;
|
||||
}
|
||||
|
||||
.answer-divider {
|
||||
margin-top: 3rem;
|
||||
margin-bottom: 3rem;
|
||||
border: 0;
|
||||
height: 1px;
|
||||
background-color: #42464e;
|
||||
}
|
@ -18,6 +18,10 @@
|
||||
</div>
|
||||
<hr />
|
||||
<h2>Answers</h2>
|
||||
{{ range $answer := .answers }}
|
||||
<div class="answer">{{ $answer }}</div>
|
||||
<hr class="answer-divider" />
|
||||
{{ end }}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user