Skip to content

Commit

Permalink
v0.1.0 (synced w/timlrx v1.5.4)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff-Russ committed Apr 25, 2022
1 parent 70bfa75 commit 7e465c6
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 44 deletions.
17 changes: 13 additions & 4 deletions components/comments/Giscus.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useTheme } from 'next-themes'

import siteMetadata from '@/data/siteMetadata'

const Giscus = ({ mapping }) => {
const Giscus = () => {
const [enableLoadComments, setEnabledLoadComments] = useState(true)
const { theme, resolvedTheme } = useTheme()
const commentsTheme =
Expand All @@ -18,8 +18,17 @@ const Giscus = ({ mapping }) => {
const LoadComments = useCallback(() => {
setEnabledLoadComments(false)

const { repo, repositoryId, category, categoryId, reactions, metadata, inputPosition, lang } =
siteMetadata?.comment?.giscusConfig
const {
repo,
repositoryId,
category,
categoryId,
mapping,
reactions,
metadata,
inputPosition,
lang,
} = siteMetadata?.comment?.giscusConfig

const script = document.createElement('script')
script.src = 'https://giscus.app/client.js'
Expand All @@ -43,7 +52,7 @@ const Giscus = ({ mapping }) => {
const comments = document.getElementById(COMMENTS_ID)
if (comments) comments.innerHTML = ''
}
}, [commentsTheme, mapping])
}, [commentsTheme])

// Reload on theme change
useEffect(() => {
Expand Down
6 changes: 3 additions & 3 deletions components/comments/Utterances.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useTheme } from 'next-themes'

import siteMetadata from '@/data/siteMetadata'

const Utterances = ({ issueTerm }) => {
const Utterances = () => {
const [enableLoadComments, setEnabledLoadComments] = useState(true)
const { theme, resolvedTheme } = useTheme()
const commentsTheme =
Expand All @@ -18,7 +18,7 @@ const Utterances = ({ issueTerm }) => {
const script = document.createElement('script')
script.src = 'https://utteranc.es/client.js'
script.setAttribute('repo', siteMetadata.comment.utterancesConfig.repo)
script.setAttribute('issue-term', issueTerm)
script.setAttribute('issue-term', siteMetadata.comment.utterancesConfig.issueTerm)
script.setAttribute('label', siteMetadata.comment.utterancesConfig.label)
script.setAttribute('theme', commentsTheme)
script.setAttribute('crossorigin', 'anonymous')
Expand All @@ -31,7 +31,7 @@ const Utterances = ({ issueTerm }) => {
const comments = document.getElementById(COMMENTS_ID)
if (comments) comments.innerHTML = ''
}
}, [commentsTheme, issueTerm])
}, [commentsTheme])

// Reload on theme change
useEffect(() => {
Expand Down
21 changes: 2 additions & 19 deletions components/comments/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,13 @@ const DisqusComponent = dynamic(
)

const Comments = ({ frontMatter }) => {
let term
const comment = siteMetadata?.comment
if (!comment || Object.keys(comment).length === 0) return <></>
switch (
siteMetadata.comment.giscusConfig.mapping ||
siteMetadata.comment.utterancesConfig.issueTerm
) {
case 'pathname':
term = frontMatter.slug
break
case 'url':
term = window.location.href
break
case 'title':
term = frontMatter.title
break
}
return (
<div id="comment">
{siteMetadata.comment && siteMetadata.comment.provider === 'giscus' && (
<GiscusComponent mapping={term} />
)}
{siteMetadata.comment && siteMetadata.comment.provider === 'giscus' && <GiscusComponent />}
{siteMetadata.comment && siteMetadata.comment.provider === 'utterances' && (
<UtterancesComponent issueTerm={term} />
<UtterancesComponent />
)}
{siteMetadata.comment && siteMetadata.comment.provider === 'disqus' && (
<DisqusComponent frontMatter={frontMatter} />
Expand Down
19 changes: 4 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tailwind-nextjs-journal",
"version": "1.5.4",
"name": "next-markdown-journal",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "cross-env SOCKET=true node ./scripts/next-remote-watch.js ./data",
Expand Down Expand Up @@ -40,7 +40,6 @@
"remark-gfm": "^3.0.1",
"remark-math": "^5.1.1",
"sharp": "^0.28.3",
"smoothscroll-polyfill": "^0.4.4",
"tailwindcss": "^3.0.23",
"unist-util-visit": "^4.0.0"
},
Expand Down

1 comment on commit 7e465c6

@vercel
Copy link

@vercel vercel bot commented on 7e465c6 Apr 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.