diff --git a/src/routes/question.go b/src/routes/question.go index 40d5b85..0eb01ec 100644 --- a/src/routes/question.go +++ b/src/routes/question.go @@ -137,7 +137,7 @@ func ViewQuestion(c *gin.Context) { newFilteredQuestion.ShortenedBody = shortenedBody - comments := utils.FindAndReturnComments(questionBodyParentHTML, questionPostLayout) + comments := utils.FindAndReturnComments(questionBodyParentHTML, domain, questionPostLayout) newFilteredQuestion.Comments = comments // parse any code blocks and highlight them @@ -256,7 +256,7 @@ func ViewQuestion(c *gin.Context) { answerBodyHTML = strings.Replace(answerBodyHTML, codeBlock, highlightedCodeBlock, 1) } - comments = utils.FindAndReturnComments(answerBodyHTML, postLayout) + comments = utils.FindAndReturnComments(answerBodyHTML, domain, postLayout) newFilteredAnswer.Comments = comments newFilteredAnswer.Body = template.HTML(utils.ReplaceImgTags(answerBodyHTML)) diff --git a/src/types/comment.go b/src/types/comment.go index b1a6b68..8213b4b 100644 --- a/src/types/comment.go +++ b/src/types/comment.go @@ -8,4 +8,5 @@ type FilteredComment struct { AuthorName string AuthorURL string Upvotes string + Domain string } diff --git a/src/utils/comments.go b/src/utils/comments.go index 7865aae..3847fc7 100644 --- a/src/utils/comments.go +++ b/src/utils/comments.go @@ -7,7 +7,7 @@ import ( "github.com/PuerkitoBio/goquery" ) -func FindAndReturnComments(inHtml string, postLayout *goquery.Selection) (comments []types.FilteredComment) { +func FindAndReturnComments(inHtml, domain string, postLayout *goquery.Selection) (comments []types.FilteredComment) { commentsComponent := postLayout.Find("div.js-post-comments-component") @@ -54,6 +54,7 @@ func FindAndReturnComments(inHtml string, postLayout *goquery.Selection) (commen AuthorName: commentAuthor.Text(), AuthorURL: commentAuthorURL, Upvotes: commentScore, + Domain: domain, } comments = append(comments, newFilteredComment) diff --git a/templates/comments.html b/templates/comments.html index 4810890..3b56b69 100644 --- a/templates/comments.html +++ b/templates/comments.html @@ -19,7 +19,7 @@
Commented {{ $comment.Timestamp }} by {{ $comment.AuthorName }}