From 579f21f515e83ec1be50dd4e85b01b633d6d4c81 Mon Sep 17 00:00:00 2001
From: Gabe Koscky <68292774+gkoscky@users.noreply.github.com>
Date: Wed, 4 Oct 2023 18:03:04 -0400
Subject: [PATCH 1/6] Set correct comment count
Discourse is very peculiar when it comes to what it counts as a "reply", so in order to get a current, sensible count we must just count all posts and subtract one, for the original post.
---
src/components/ForumWidget/ForumWidget.tsx | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/components/ForumWidget/ForumWidget.tsx b/src/components/ForumWidget/ForumWidget.tsx
index c2020429..1e3465d2 100644
--- a/src/components/ForumWidget/ForumWidget.tsx
+++ b/src/components/ForumWidget/ForumWidget.tsx
@@ -24,7 +24,10 @@ const ForumWidget = () => {
const {
posts_count
} = res.data
- setCommentAmount(posts_count)
+ // Discourse topics don't have a separate count just for replies so we must
+ // get the full count of posts and subtract one, for the original post
+ // https://meta.discourse.org/t/how-to-get-accurate-reply-count-through-api/144267/2
+ setCommentAmount(posts_count - 1)
}, [forum_link])
useEffect(() => {
From a817d14c11b37e357bb406478d05494a951c7672 Mon Sep 17 00:00:00 2001
From: Gabe Koscky <68292774+gkoscky@users.noreply.github.com>
Date: Wed, 4 Oct 2023 18:04:53 -0400
Subject: [PATCH 2/6] Fix comment-button styling
The button was disappearing in dark mode
The alignment was also off
And the color was changing on hover in Firefox
---
src/components/ForumWidget/ForumWidget.tsx | 2 +-
src/components/ForumWidget/styles.module.scss | 21 +++++++++----------
2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/src/components/ForumWidget/ForumWidget.tsx b/src/components/ForumWidget/ForumWidget.tsx
index 1e3465d2..6a0b36f0 100644
--- a/src/components/ForumWidget/ForumWidget.tsx
+++ b/src/components/ForumWidget/ForumWidget.tsx
@@ -41,7 +41,7 @@ const ForumWidget = () => {
diff --git a/src/components/ForumWidget/styles.module.scss b/src/components/ForumWidget/styles.module.scss
index 07cde9b4..99821b3e 100644
--- a/src/components/ForumWidget/styles.module.scss
+++ b/src/components/ForumWidget/styles.module.scss
@@ -1,7 +1,7 @@
.root {
display: flex;
font-size: 13px;
- border: 1px solid #CCD0D5;
+ border: 1px solid #ccd0d5;
border-radius: 24px;
line-height: 16px;
display: flex;
@@ -10,7 +10,9 @@
padding: 4px 8px 5px;
gap: 4px;
width: fit-content;
- margin-top: .25rem;
+ margin-top: 0.25rem;
+ color: var(--ifm-font-color-base);
+
& > * {
flex: none;
order: 1;
@@ -18,9 +20,7 @@
}
&:hover {
text-decoration: none;
- }
- & span {
- color: #1C1E21;
+ color: unset;
}
}
@@ -28,10 +28,9 @@
display: flex;
align-items: center;
justify-content: center;
- margin-right: 5px;
- & img {
- width: 100%;
- }
-
-}
\ No newline at end of file
+ & svg {
+ position: relative;
+ top: 1px;
+ }
+}
From 5d2c10321ee4e50d0b721fc7eafa7cb47309e285 Mon Sep 17 00:00:00 2001
From: Gabe Koscky <68292774+gkoscky@users.noreply.github.com>
Date: Wed, 4 Oct 2023 18:07:14 -0400
Subject: [PATCH 3/6] Avoid comment button on empty forum_link
If the `forum_link` property was present on a post but had no value, the "Leave a reply" button would be rendered but not be a link (since we have no href).
So let's check for any valid `forum_link` instead of just not undefined
---
src/components/ForumWidget/ForumWidget.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/components/ForumWidget/ForumWidget.tsx b/src/components/ForumWidget/ForumWidget.tsx
index 6a0b36f0..9d93e338 100644
--- a/src/components/ForumWidget/ForumWidget.tsx
+++ b/src/components/ForumWidget/ForumWidget.tsx
@@ -37,7 +37,7 @@ const ForumWidget = () => {
}, [forum_link])
return (
- forum_link !== undefined ?
+ forum_link ?