Skip to content

Commit 3cb9c7c

Browse files
authored
Fix: Null issue comments and markdown rendering (#98)
* intall necessary dependencies * add markdown wrapper to issue comment body * fix issue comment returning empty values for next year
1 parent f498d13 commit 3cb9c7c

File tree

6 files changed

+692
-10
lines changed

6 files changed

+692
-10
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"next": "13.5.4",
1919
"next-auth": "^4.24.4",
2020
"react": "^18",
21-
"react-dom": "^18"
21+
"react-dom": "^18",
22+
"react-markdown": "^9.0.1"
2223
},
2324
"devDependencies": {
2425
"@types/node": "^20",

src/app/components/collapsible/issues/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
contentHeading,
1313
getIssueNumber
1414
} from "@/helpers/utils"
15+
import { MarkdownWrapper } from "../../wrapper/MarkdownWrapper"
1516

1617
type CollapsibleIssueProps = {
1718
issues: Comment[]
@@ -89,9 +90,10 @@ const CollaspsibleIssue = ({
8990
{issue.url}
9091
</Link>
9192
</section>
92-
<p className="text-sm text-black">
93-
{issue.body}
94-
</p>
93+
<MarkdownWrapper
94+
summary={issue.body}
95+
className="text-sm text-black"
96+
/>
9597

9698
<div className="flex flex-row w-full gap-3 items-center text-xs text-black">
9799
<section className="flex items-center w-max gap-2">
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from "react"
2+
import ReactMarkdown from "react-markdown"
3+
import "../../globals.css"
4+
5+
export const MarkdownWrapper = ({
6+
summary,
7+
className
8+
}: {
9+
summary: string
10+
className?: string | null | undefined
11+
}) => {
12+
return (
13+
<ReactMarkdown className={`markdownStyles ${className}`}>
14+
{summary}
15+
</ReactMarkdown>
16+
)
17+
}

src/app/globals.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,15 @@ body {
4040
.arrowLeftIcon:hover {
4141
background-color: #eeeeee;
4242
}
43+
44+
.markdownStyles p {
45+
margin: 16px 0px;
46+
}
47+
48+
.summaryTags p {
49+
margin: 0px 0px;
50+
}
51+
52+
.markdownStyles a {
53+
text-decoration: underline;
54+
}

src/helpers/get-issues-data.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,17 @@ export async function getIssueCommentsData({
7474

7575
const data = await res.json()
7676
const jsonData: IssueCommentDataType = data.data.user
77+
const {
78+
startCursor,
79+
hasNextPage: pageHasNextPage,
80+
endCursor: pageEndCursor
81+
} = jsonData?.issueComments?.pageInfo
7782

7883
const nodes_data = jsonData?.issueComments?.nodes
79-
const start_cursor = jsonData?.issueComments?.pageInfo?.startCursor
80-
const isNextPage = jsonData?.issueComments?.pageInfo?.hasNextPage
81-
const end_cursor = jsonData?.issueComments?.pageInfo?.endCursor
84+
const start_cursor = startCursor
85+
const isNextPage = pageHasNextPage
86+
const end_cursor =
87+
nodes_data.length >= 100 ? pageEndCursor : startCursor
8288

8389
// get previous year from start date of query
8490
const prevYear = Number(getYearFromDate) - 1

0 commit comments

Comments
 (0)