File tree Expand file tree Collapse file tree 5 files changed +75
-0
lines changed
Expand file tree Collapse file tree 5 files changed +75
-0
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ const config: Config = {
123123 theme : prismThemes . github ,
124124 darkTheme : prismThemes . dracula ,
125125 } ,
126+ discourseUrl : 'https://discourse.bemanproject.org/' , // Temporary change, re-deploy.
126127 } satisfies Preset . ThemeConfig ,
127128} ;
128129
Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff line change 1+ import React , { useEffect } from 'react' ;
2+ import useDocusaurusContext from '@docusaurus/useDocusaurusContext' ;
3+
4+ type DiscourseEmbedWindow = Window & {
5+ DiscourseEmbed ?: {
6+ discourseUrl : string ;
7+ discourseEmbedUrl : string ;
8+ discourseTopicTitle ?: string ;
9+ } ;
10+ } ;
11+
12+ export default function DiscourseComments ( ) : JSX . Element {
13+ const {
14+ siteConfig : {
15+ themeConfig : { discourseUrl } ,
16+ } ,
17+ } = useDocusaurusContext < { discourseUrl : string } > ( ) ;
18+
19+ useEffect ( ( ) => {
20+ const win = window as DiscourseEmbedWindow ;
21+
22+ if ( ! win . DiscourseEmbed ) {
23+ const forum = discourseUrl . endsWith ( '/' ) ? discourseUrl : `${ discourseUrl } /` ;
24+ const path = window . location . pathname ;
25+
26+ // Use production URL only if not localhost
27+ const isLocal = window . location . hostname === 'localhost' ;
28+ const base = isLocal
29+ ? 'https://bemanproject.org'
30+ : `${ window . location . origin } ` ;
31+
32+ win . DiscourseEmbed = {
33+ discourseUrl : forum ,
34+ discourseEmbedUrl : `${ base } ${ path } ` ,
35+ } ;
36+
37+ const script = document . createElement ( 'script' ) ;
38+ script . src = `${ forum } javascripts/embed.js` ;
39+ script . async = true ;
40+ document . body . appendChild ( script ) ;
41+ }
42+ } , [ discourseUrl ] ) ;
43+
44+ return < div id = "discourse-comments" style = { { marginTop : '2rem' } } /> ;
45+ }
Original file line number Diff line number Diff line change 1+ import React , { type ReactNode } from 'react' ;
2+ import BlogPostItem from '@theme-original/BlogPostItem' ;
3+ import type BlogPostItemType from '@theme/BlogPostItem' ;
4+ import type { WrapperProps } from '@docusaurus/types' ;
5+
6+ // 1) Import your DiscourseComments
7+ import DiscourseComments from '@site/src/components/DiscourseComments' ;
8+
9+ type Props = WrapperProps < typeof BlogPostItemType > ;
10+
11+ export default function BlogPostItemWrapper ( props : Props ) : ReactNode {
12+ return (
13+ < >
14+ { /* 2) Render the original blog content */ }
15+ < BlogPostItem { ...props } />
16+
17+ { /* 3) Then render Discourse comments */ }
18+ < DiscourseComments />
19+ </ >
20+ ) ;
21+ }
Original file line number Diff line number Diff line change 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"
You can’t perform that action at this time.
0 commit comments