From e6915ae849a70e8723d6a6f45fde4bf415d3c951 Mon Sep 17 00:00:00 2001 From: httpjamesm Date: Thu, 29 Dec 2022 13:11:33 -0500 Subject: [PATCH] fix: re-add question comments --- src/routes/question.go | 1 + src/types/question.go | 1 + templates/question.html | 28 ++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/src/routes/question.go b/src/routes/question.go index de14ca5..23ad8c8 100644 --- a/src/routes/question.go +++ b/src/routes/question.go @@ -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) diff --git a/src/types/question.go b/src/types/question.go index 1aeba70..2850532 100644 --- a/src/types/question.go +++ b/src/types/question.go @@ -9,4 +9,5 @@ type FilteredQuestion struct { AuthorName string AuthorURL string ShortenedBody string + Comments []FilteredComment } diff --git a/templates/question.html b/templates/question.html index c10896c..ac498f4 100644 --- a/templates/question.html +++ b/templates/question.html @@ -46,6 +46,34 @@

{{ .question.Body }}
+ {{ if .question.Comments }} +
+ + Show {{ (len .question.Comments) }} comments + +
+ {{ range $comment := .question.Comments }} +
+
+
+ {{ $comment.Text }} +
+
+ Commented {{ $comment.Timestamp }} by + {{ $comment.AuthorName }}. +
+
+
+ {{end}} +
+
+ {{end}} +

Answers