Skip to content

Commit 3908bf7

Browse files
authored
Add initial prototype for comments (#92)
* Add initial prototype for comments Signed-off-by: Radu Nichita <radunichita99@gmail.com>
1 parent 66b893a commit 3908bf7

File tree

5 files changed

+50
-0
lines changed

5 files changed

+50
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ authors: ["camio"]
44
tags: ["hackathon", "beman"]
55
---
66

7+
import DiscourseComments from '@site/src/components/DiscourseComments';
8+
79
# NYC Hackathon
810

911
![busy coding](./images/hacking.jpg "Several hackathon members busy coding. They give the impression of serious and intense work happening!")
@@ -33,3 +35,5 @@ Overall it was productive and a ton of fun. Thanks to Robert, Eddie, Linus,
3335
River, Nick, Bret, and Robert for participating!
3436

3537
![portrait of attendees](./images/final-photo.jpg "All the hackathon folks standing together in a portrait looking very cool.")
38+
39+
<DiscourseComments />

docusaurus.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ const config: Config = {
123123
theme: prismThemes.github,
124124
darkTheme: prismThemes.dracula,
125125
},
126+
discourseUrl: 'https://discourse.bemanproject.org/',
126127
} satisfies Preset.ThemeConfig,
127128
};
128129

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@docusaurus/preset-classic": "3.7.0",
2020
"@mdx-js/react": "^3.0.0",
2121
"@remark-embedder/core": "^3.0.3",
22+
"@remark-embedder/transformer-oembed": "^5.0.1",
2223
"clsx": "^2.0.0",
2324
"prism-react-renderer": "^2.3.0",
2425
"react": "^19.0.0",
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React, { useEffect } from 'react';
2+
import type { Props } from '@docusaurus/types';
3+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
4+
5+
type DiscourseEmbedWindow = Window & {
6+
DiscourseEmbed?: {
7+
discourseUrl: string;
8+
discourseEmbedUrl: string;
9+
discourseTopicTitle?: string;
10+
};
11+
};
12+
13+
export default function DiscourseComments(): JSX.Element {
14+
const {
15+
siteConfig: {
16+
themeConfig: { discourseUrl },
17+
},
18+
} = useDocusaurusContext<{ discourseUrl: string }>();
19+
20+
useEffect(() => {
21+
const win = window as DiscourseEmbedWindow;
22+
if (!win.DiscourseEmbed) {
23+
// normalize URL to end with a single slash
24+
const forum = https://discourse.example.com/
25+
win.DiscourseEmbed = {
26+
discourseUrl: forum,
27+
discourseEmbedUrl: "https://discourse.bemanproject.org/t/test-topic-for-blog-comments/472"
28+
};
29+
const script = document.createElement('script');
30+
script.src = forum + 'javascripts/embed.js';
31+
script.async = true;
32+
document.body.appendChild(script);
33+
}
34+
}, [discourseUrl]);
35+
36+
return <div id="discourse-comments" style={{ marginTop: '2rem' }} />;
37+
}

yarn.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,6 +2033,13 @@
20332033
unified "^11.0.4"
20342034
unist-util-visit "^5.0.0"
20352035

2036+
"@remark-embedder/transformer-oembed@^5.0.1":
2037+
version "5.0.1"
2038+
resolved "https://registry.yarnpkg.com/@remark-embedder/transformer-oembed/-/transformer-oembed-5.0.1.tgz#7734d3ecb1ea101447832f6350c5ebf0b249380c"
2039+
integrity sha512-NKR9WYyzI74iZ1nWVXcKQ9dz1xIBuN3nONqVsRbyp9yVZJv8tCi25BSVmgVQtqaNsEjbSemEp8yp+hwQzuLVxg==
2040+
dependencies:
2041+
"@babel/runtime" "^7.24.5"
2042+
20362043
"@sideway/address@^4.1.5":
20372044
version "4.1.5"
20382045
resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.5.tgz#4bc149a0076623ced99ca8208ba780d65a99b9d5"

0 commit comments

Comments
 (0)