-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat/refactor: reddit comments (#104)
- Loading branch information
1 parent
233878c
commit b9a715a
Showing
4 changed files
with
59 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import useDarkMode from '../../hooks/useDarkMode'; | ||
import useScript from '../../hooks/useScript'; | ||
|
||
interface RedditCommentEmbedProps { | ||
commentUrl: string; | ||
postAuthor: string; | ||
discussionUrl: string; | ||
subreddit: string; | ||
height: number; | ||
} | ||
|
||
export default function RedditComment({ | ||
commentUrl, | ||
postAuthor, | ||
discussionUrl, | ||
subreddit, | ||
height, | ||
}: RedditCommentEmbedProps) { | ||
const { isDark } = useDarkMode(); | ||
useScript('https://embed.reddit.com/widgets.js'); | ||
|
||
return ( | ||
<blockquote | ||
className="reddit-embed-bq" | ||
style={{ height: `${height.toString()}px` }} | ||
data-embed-height={height.toString()} | ||
data-embed-theme={isDark ? 'dark' : 'light'} | ||
> | ||
<a href={commentUrl}>Comment</a> | ||
<br /> | ||
by | ||
<a href={`https://www.reddit.com/user/${postAuthor}/`}>u/{postAuthor}</a> | ||
from discussion | ||
<a href={discussionUrl}>s</a> | ||
<br /> | ||
in | ||
<a href={`https://www.reddit.com/r/${subreddit}/`}>{subreddit}</a> | ||
</blockquote> | ||
); | ||
} |
14 changes: 8 additions & 6 deletions
14
components/RedditPost.tsx → components/Reddit/RedditPost.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import dynamic from 'next/dynamic'; | ||
|
||
export const RedditPost = dynamic(() => import('./RedditPost'), { | ||
ssr: false, | ||
}); | ||
|
||
export const RedditComment = dynamic(() => import('./RedditComment'), { | ||
ssr: false, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters