Skip to content

Commit f221966

Browse files
authored
Merge pull request #159 from dassiorleando/fix-disqus-url
Improved disqus settings to use the provided site URL.
2 parents 82fae9a + 139200e commit f221966

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

‎components/DisqusComments.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import { DiscussionEmbed } from 'disqus-react'
22
import { GhostPostOrPage } from '@lib/ghost'
3+
import { resolvePostFullPath } from '@utils/routing'
34

45
interface DisqusCommentsProps {
56
post: GhostPostOrPage
67
shortname: string
8+
siteUrl: string
79
}
810

9-
export const DisqusComments = ({ post, shortname }: DisqusCommentsProps) => {
10-
const { url, id: identifier, title } = post
11+
export const DisqusComments = ({ post, shortname, siteUrl }: DisqusCommentsProps) => {
12+
const url = resolvePostFullPath(siteUrl, post.slug)
13+
const { id: identifier, title } = post
1114
const config = { url, identifier, title }
1215

1316
return (

‎components/Post.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export const Post = ({ cmsData }: PostProps) => {
156156

157157
{commenting.system === 'commento' && <CommentoComments {...{ id: post.id, url: commenting.commentoUrl }} />}
158158

159-
{commenting.system === 'disqus' && <DisqusComments {...{ post, shortname: commenting.disqusShortname }} />}
159+
{commenting.system === 'disqus' && <DisqusComments {...{ post, shortname: commenting.disqusShortname, siteUrl: processEnv.siteUrl }} />}
160160
</article>
161161
</div>
162162
</Layout>

‎utils/routing.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,7 @@ export const resolveUrl = ({ cmsUrl, collectionPath = `/`, slug, url }: ResolveU
3838
const dirUrl = url.replace(cmsUrl, '/').replace('//', '/')
3939
return resolvePath(dirUrl)
4040
}
41+
42+
export const resolvePostFullPath = (siteUrl: string, slug: string) => {
43+
return `${trimSlash(siteUrl)}/${slug}`
44+
}

0 commit comments

Comments
 (0)