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{
|
c.HTML(200, "question.html", gin.H{
|
||||||
"title": questionText,
|
"title": questionText,
|
||||||
"body": template.HTML(questionBodyParentHTML),
|
"body": template.HTML(questionBodyParentHTML),
|
||||||
"timestamp": questionTimestamp,
|
"timestamp": questionTimestamp,
|
||||||
"author": questionAuthor,
|
"author": questionAuthor,
|
||||||
"authorURL": questionAuthorURL,
|
"authorURL": questionAuthorURL,
|
||||||
|
"answers": answers,
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -30,6 +30,11 @@ body {
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.parent {
|
||||||
|
max-width: 90%;
|
||||||
|
width: fit-content;
|
||||||
|
}
|
||||||
|
|
||||||
code {
|
code {
|
||||||
background-color: var(--code-bg);
|
background-color: var(--code-bg);
|
||||||
padding: .15rem;
|
padding: .15rem;
|
||||||
@ -54,4 +59,12 @@ pre {
|
|||||||
|
|
||||||
a {
|
a {
|
||||||
color: #92adff;
|
color: #92adff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.answer-divider {
|
||||||
|
margin-top: 3rem;
|
||||||
|
margin-bottom: 3rem;
|
||||||
|
border: 0;
|
||||||
|
height: 1px;
|
||||||
|
background-color: #42464e;
|
||||||
}
|
}
|
@ -18,6 +18,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
<h2>Answers</h2>
|
<h2>Answers</h2>
|
||||||
|
{{ range $answer := .answers }}
|
||||||
|
<div class="answer">{{ $answer }}</div>
|
||||||
|
<hr class="answer-divider" />
|
||||||
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user