Skip to content

Commit 6121077

Browse files
authored
Enable comments on blog post pages (#46)
2 parents fa09310 + c7ed32d commit 6121077

File tree

8 files changed

+129
-16
lines changed

8 files changed

+129
-16
lines changed

blog/2024-03-04-on-implementation-of-distributed-prtocols/index.mdx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,3 @@ It does not mean at all that exploration, ideation, and prototyping will not tak
407407
import Admonition from '@theme/Admonition';
408408

409409
<Admonition type="info" icon="❤️" title="Supporting">If you like the project and find it valuable, please <a href="https://github.com/sponsors/replica-io">support</a> its further development! 🙏</Admonition>
410-
411-
:::tip
412-
413-
If you have any thought you would like to share or any question regarding this post, please add a comment [here](https://github.com/orgs/replica-io/discussions/35). You are also welcome to [start a new discussion](https://github.com/orgs/replica-io/discussions/new/choose) or chime in to [our Discord](https://discordapp.com/invite/CzPfN75URD) server.
414-
415-
:::

blog/2024-08-27-on-frameworks-for-implementing-distributed-protocols/index.mdx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,3 @@ import Admonition from '@theme/Admonition';
161161
<Admonition type="info" icon="❤️" title="Supporting">
162162
If you like the project and find it valuable, please <a href="https://github.com/sponsors/replica-io">support</a> its further development! 🙏
163163
</Admonition>
164-
165-
:::note
166-
167-
If you have any thought you would like to share or any question regarding this post, please add a comment [here](https://github.com/orgs/replica-io/discussions/43). You are also welcome to [start a new discussion](https://github.com/orgs/replica-io/discussions/new) or chime in to [our Discord](https://discord.replica-io.dev/) server.
168-
169-
:::

blog/_template.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ title:
33
description:
44
authors:
55
image:
6-
keywords: []
76
tags: []
7+
keywords: []
88
hide_table_of_contents: false
9+
disableComments: false
910
---
1011

1112

1213

13-
{/* Summary part ends here */}
14-
{/*truncate*/}
14+
<!-- Summary part ends here -->
15+
<!--truncate-->
1516

docusaurus.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,17 @@ const config = {
3232
description: 'An open-source framework for building practical distributed replication mechanisms.',
3333
gitHubUrl: gitHubUrl,
3434
siteLicense: siteLicense,
35-
recentBlogPostsOnHomePage: 5
35+
recentBlogPostsOnHomePage: 5,
36+
giscusConfig: {
37+
repo: 'replica-io/replica-io',
38+
repoId: 'R_kgDOJGevLg',
39+
category: 'General',
40+
categoryId: 'DIC_kwDOJGevLs4CUted',
41+
reactionsEnabled: '1',
42+
inputPosition: 'top',
43+
loading: 'lazy',
44+
themes: {light: 'light', dark: 'transparent_dark'},
45+
},
3646
},
3747

3848
// GitHub pages deployment config.

package-lock.json

Lines changed: 74 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"@docusaurus/core": "^3.8.0",
1818
"@docusaurus/preset-classic": "^3.8.0",
1919
"@fortawesome/fontawesome-free": "^6.6.0",
20+
"@giscus/react": "^3.1.0",
2021
"@mdx-js/react": "^3.0.1",
2122
"botex": "^1.0.0",
2223
"clsx": "^2.1.1",
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Giscus from '@giscus/react';
2+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
3+
import { useColorMode } from '@docusaurus/theme-common';
4+
5+
export default function GiscusComments(props) {
6+
const { colorMode } = useColorMode();
7+
const { siteConfig, i18n } = useDocusaurusContext();
8+
const { giscusConfig } = siteConfig.customFields;
9+
10+
return (
11+
<Giscus
12+
id='comments'
13+
mapping='specific'
14+
strict='0' /* We don't include title hash in discussion body */
15+
term={props.title}
16+
theme={giscusConfig.themes[colorMode] || colorMode}
17+
lang={i18n.lang}
18+
{...giscusConfig}
19+
/>
20+
);
21+
}

src/theme/BlogPostItem/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react';
2+
import BlogPostItem from '@theme-original/BlogPostItem';
3+
import GiscusComments from '@site/src/components/GiscusComments';
4+
import { useBlogPost } from '@docusaurus/plugin-content-blog/client';
5+
6+
export default function BlogPostItemWrapper(props) {
7+
const { metadata, isBlogPostPage } = useBlogPost();
8+
const { title, frontMatter: { disableComments } } = metadata;
9+
10+
return (
11+
<>
12+
<BlogPostItem {...props} />
13+
{isBlogPostPage && !disableComments && (
14+
<GiscusComments title={title}/>
15+
)}
16+
</>
17+
);
18+
}

0 commit comments

Comments
 (0)