-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
86 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
sidebar_label: Discussion | ||
title: Discussion | ||
draft: true | ||
--- | ||
|
||
import GiscusComponent from '@site/src/components/Github/Discussions'; | ||
|
||
# My Awesome Documentation Page | ||
|
||
This is a great place to have discussions about our content. | ||
<GiscusComponent /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React, { useEffect } from 'react'; | ||
|
||
const GitHubComments = ({ repo, issueTerm = 'pathname', label = 'discussion', theme = 'github-light' }) => { | ||
useEffect(() => { | ||
// Cleanup existing script to reconfigure or reinitialize when props change | ||
const existingScript = document.getElementById('github-discussion-script'); | ||
if (existingScript) { | ||
existingScript.remove(); | ||
} | ||
|
||
const script = document.createElement('script'); | ||
script.id = 'github-comments-script'; // Unique ID for the script tag | ||
script.src = 'https://utteranc.es/client.js'; | ||
script.async = true; | ||
script.setAttribute('repo', repo); | ||
script.setAttribute('issue-term', issueTerm); | ||
script.setAttribute('label', label); | ||
script.setAttribute('theme', theme); | ||
script.crossOrigin = 'anonymous'; | ||
|
||
const anchor = document.getElementById('github-comments'); | ||
if (anchor) { | ||
anchor.innerHTML = ''; // Clear previous content | ||
anchor.appendChild(script); | ||
} | ||
|
||
// Cleanup function to remove script on component unmount | ||
return () => { | ||
script.remove(); | ||
}; | ||
}, [repo, issueTerm, label, theme]); // Re-run the effect if these props change | ||
|
||
return <div id="github-comments"></div>; | ||
}; | ||
|
||
export default GitHubComments; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,28 @@ | ||
import React, { useEffect } from 'react'; | ||
|
||
const GitHubDiscussions = ({ repo, issueTerm = 'pathname', label = 'discussion', theme = 'github-light' }) => { | ||
const GiscusComponent = () => { | ||
useEffect(() => { | ||
// Cleanup existing script to reconfigure or reinitialize when props change | ||
const existingScript = document.getElementById('github-discussion-script'); | ||
if (existingScript) { | ||
existingScript.remove(); | ||
} | ||
|
||
const script = document.createElement('script'); | ||
script.id = 'github-discussion-script'; // Unique ID for the script tag | ||
script.src = 'https://utteranc.es/client.js'; | ||
script.src = 'https://giscus.app/client.js'; | ||
script.async = true; | ||
script.setAttribute('repo', repo); | ||
script.setAttribute('issue-term', issueTerm); | ||
script.setAttribute('label', label); | ||
script.setAttribute('theme', theme); | ||
script.crossOrigin = 'anonymous'; | ||
|
||
const anchor = document.getElementById('github-discussions'); | ||
if (anchor) { | ||
anchor.innerHTML = ''; // Clear previous content | ||
anchor.appendChild(script); | ||
} | ||
script.setAttribute('data-repo', 'saviynt/developer-portal'); | ||
script.setAttribute('data-repo-id', 'R_kgDOLnTSUg'); | ||
script.setAttribute('data-category', 'General'); | ||
script.setAttribute('data-category-id', 'DIC_kwDOLnTSUs4Cel7H'); | ||
script.setAttribute('data-mapping', 'pathname'); | ||
script.setAttribute('data-reactions-enabled', '1'); | ||
script.setAttribute('data-emit-metadata', '0'); | ||
script.setAttribute('data-theme', 'light'); | ||
script.setAttribute('data-lang', 'en'); | ||
script.setAttribute('crossorigin', 'anonymous'); | ||
document.body.appendChild(script); | ||
|
||
// Cleanup function to remove script on component unmount | ||
return () => { | ||
script.remove(); | ||
document.body.removeChild(script); | ||
}; | ||
}, [repo, issueTerm, label, theme]); // Re-run the effect if these props change | ||
}, []); | ||
|
||
return <div id="github-discussions"></div>; | ||
return <div className="giscus" />; | ||
}; | ||
|
||
export default GitHubDiscussions; | ||
export default GiscusComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.