fix: re-add question comments

This commit is contained in:
httpjamesm 2022-12-29 13:11:33 -05:00
parent 572fac9ec3
commit e6915ae849
3 changed files with 30 additions and 0 deletions

View File

@ -74,6 +74,7 @@ func ViewQuestion(c *gin.Context) {
newFilteredQuestion.ShortenedBody = shortenedBody
comments := utils.FindAndReturnComments(questionBodyParentHTML, questionPostLayout)
newFilteredQuestion.Comments = comments
// parse any code blocks and highlight them
answerCodeBlocks := questionCodeBlockRegex.FindAllString(questionBodyParentHTML, -1)

View File

@ -9,4 +9,5 @@ type FilteredQuestion struct {
AuthorName string
AuthorURL string
ShortenedBody string
Comments []FilteredComment
}

View File

@ -46,6 +46,34 @@
</p>
</div>
<div class="card-body">{{ .question.Body }}</div>
{{ if .question.Comments }}
<details class="comments">
<summary>
Show <b>{{ (len .question.Comments) }} comments</b>
</summary>
<div class="comments-parent">
{{ range $comment := .question.Comments }}
<div class="comment-parent">
<div class="comment">
<div class="comment-body">
{{ $comment.Text }}
</div>
<div class="comment-author">
Commented {{ $comment.Timestamp }} by
<a
href="https://stackoverflow.com{{ $comment.AuthorURL }}"
target="_blank"
rel="noopener noreferrer"
>{{ $comment.AuthorName }}</a
>.
</div>
</div>
</div>
{{end}}
</div>
</details>
{{end}}
</div>
<hr class="post-divider" />
<h2>Answers</h2>