Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support cusdis #102

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 21 additions & 1 deletion components/NotionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { Footer } from './Footer'
import { PageSocial } from './PageSocial'
import { GitHubShareButton } from './GitHubShareButton'
import { ReactUtterances } from './ReactUtterances'

import { ReactCusdis } from 'react-cusdis'
import styles from './styles.module.css'

// const Code = dynamic(() =>
Expand Down Expand Up @@ -148,6 +148,26 @@ export const NotionPage: React.FC<types.PageProps> = ({
theme={darkMode.value ? 'photon-dark' : 'github-light'}
/>
)
} else if (config.cusdis) {
if (!config.cusdis.appId) {
console.warn('[cusdis]', 'appId is required')
}
comments = (
<ReactCusdis
style={{
width: "100%"
}}
lang={config.cusdis.lang}
attrs={{
...config.cusdis,
host: config.cusdis.host || 'https://cusdis.com',
appId: config.cusdis.appId,
pageId: pageId,
pageTitle: title,
pageUrl: typeof location !== 'undefined' ? location.href : undefined
}}
></ReactCusdis>
)
}

const tweet = getPageTweet(block, recordMap)
Expand Down
6 changes: 6 additions & 0 deletions lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ export const utterancesGitHubRepo: string | null = getSiteConfig(
null
)

// Optional Cusdis widget https://cusdis.com
export const cusdis = getSiteConfig(
'cusdis',
null
)

// Optional image CDN host to proxy all image requests through
export const imageCDNHost: string | null = getSiteConfig('imageCDNHost', null)

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"p-memoize": "^4.0.0",
"react": "^17.0.2",
"react-body-classname": "^1.3.1",
"react-cusdis": "^2.0.1",
"react-dom": "^17.0.2",
"react-icons": "^4.2.0",
"react-notion-x": "^4.5.2",
Expand Down
3 changes: 3 additions & 0 deletions site.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ module.exports = {
// Utteranc.es comments via GitHub issue comments (optional)
utterancesGitHubRepo: null,

// Cusdis comment widget (optional)
cusdis: null,

// whether or not to enable support for LQIP preview images (optional)
// NOTE: this requires you to set up Google Firebase and add the environment
// variables specified in .env.example
Expand Down
6 changes: 6 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@
resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.3.tgz#9c088679876f374eb5983f150d4787aa6fb32d7e"
integrity sha512-FvUupuM3rlRsRtCN+fDudtmytGO6iHJuuRKS1Ss0pG5z8oX0diNEw94UEL7hgDbpN94rgaK5R7sWm6RrSkZuAQ==


"@typescript-eslint/eslint-plugin@^4.22.0":
version "4.22.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.22.0.tgz#3d5f29bb59e61a9dba1513d491b059e536e16dbc"
Expand Down Expand Up @@ -4428,6 +4429,11 @@ react-body-classname@^1.3.1:
prop-types "^15.5.6"
react-side-effect "^1.1.0 || ^2.1.0"

react-cusdis@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/react-cusdis/-/react-cusdis-2.0.1.tgz#88d8a8e88be9c8a80b33974d151311c3378acc7a"
integrity sha512-8oWF5GdsKUx+l9A58GkYJc6yiYNiF7vw9cZHGLcX0z2MyznwLXizBgPfIFvVV7kdsapdjeium/Ox1J3rR+ZQnw==

react-dom@^17.0.2:
version "17.0.2"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-17.0.2.tgz#ecffb6845e3ad8dbfcdc498f0d0a939736502c23"
Expand Down