Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/discourse embed testing #614

Closed
wants to merge 13 commits into from
40 changes: 40 additions & 0 deletions src/components/discourse/discourseEmbed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React, { useEffect } from 'react';

const DiscourseEmbed = ({ discourseEmbedUrl }) => {
useEffect(() => {
// Ensure discourseUrl is correct and ending with '/'
const discourseUrl = 'https://developer.sailpoint.com/discuss/';

// Ensure the script source URL is correct
const scriptSrc = `${discourseUrl}plugins/discourse-sailpoint-plugin/javascripts/embed.js`;

// Set up Discourse Embed
window.DiscourseEmbed = { discourseUrl, topicId: 19918, showComments: false };

// Create and append meta tag for discourse username
const metaTag = document.createElement('meta');
metaTag.name = 'discourse-username';
metaTag.content = 'Darrell-Thobe';
metaTag.setAttribute('referrerpolicy', 'no-referrer-when-downgrade'); // Set referrerpolicy
document.head.appendChild(metaTag);

// Create and append Discourse embed script
const scriptTag = document.createElement('script');
scriptTag.type = 'text/javascript';
scriptTag.async = true;
scriptTag.src = scriptSrc;
document.body.appendChild(scriptTag); // Append to body

// Cleanup on component unmount
return () => {
scriptTag.remove(); // Remove script tag
if (metaTag.parentNode) {
metaTag.parentNode.removeChild(metaTag); // Remove meta tag
}
};
}, []); // Dependency array left empty if discourseEmbedUrl is not used

return <div id="discourse-comments"></div>; // Container for the Discourse comments
};

export default DiscourseEmbed;
3 changes: 3 additions & 0 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import HomepageBasics from '../components/homepage/HomepageBasics';
import HomepageTrainingGuides from '../components/homepage/HomepageTrainingGuides';
import HomepageDiscuss from '../components/homepage/HomepageDiscuss';
import HomepageTeam from '../components/homepage/HomepageTeam';
import DiscourseEmbed from '../components/discourse/discourseEmbed';

import styles from './index.module.css';

Expand All @@ -17,6 +18,7 @@ export default function Home() {
return (
<Layout description="The SailPoint Developer Community has everything you need to build, extend, and automate scalable identity solutions.">
<main>

<HomepageGettingStarted />
{/* <HomepageDeveloperDays /> */}
<HomepageBasics
Expand All @@ -29,6 +31,7 @@ export default function Home() {
buttonText={'Explore our platform'}
/>
<HomepageTrainingGuides />
<DiscourseEmbed />
<HomepageBasics
description={
'The SailPoint Developer Forums are a great place to find solutions to common development problems.'
Expand Down
Loading