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

Implement Giscus comment/like React component for blog #2

Closed
wants to merge 1 commit into from

Conversation

ayaan-d
Copy link
Member

@ayaan-d ayaan-d commented May 20, 2024

Created a React component to be added to blog pages to integrate the Giscus comment/like system (Project #2). The repo will have to be setup with Giscus to add the env variables.

Tested locally on fork and will look like the image seen below:

Screenshot 2024-05-19 205041

Copy link
Member

@ben-z ben-z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Do you have access to the internal repo https://github.com/WATonomous/infra-config ? Can you open a pull request in there?

mapping="pathname"
reactionsEnabled="1"
emitMetadata="0"
theme="dark"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we set this dynamically? Example:

theme={darkMode === true ? "dark" : darkMode === false ? "light" : "system"}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any context as to how the darkMode variable is set? I am trying to do this but it seems to always be set as true. Also, would something like a useEffect() be able to update the comments component to change theme even after the page is rendered?

Copy link
Member

@ben-z ben-z May 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable should be set according to the setting near the footer on every page:
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, even if I load the page with light mode the variable is still showing up as true not sure why

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, perhaps try this approach instead? I do remember one of these approaches didn't work as expected during development, but didn't look too deeply into it.

const { theme } = useTheme();
const uppyTheme = theme === 'dark' ? 'dark' : theme === 'light' ? 'light' : 'auto';

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed to work. I'll create a new PR once I have access to the infra-config repo. Thanks for the help!

@@ -27,6 +27,7 @@
"homepage": "https://github.com/WATonomous/infra-config#readme",
"description": "A website for WATcloud",
"dependencies": {
"@giscus/react": "^3.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there no changes in package-lock.json?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes there was I'll add it

@@ -64,6 +65,7 @@
"react-dom": "^18.2.0",
"react-hook-form": "^7.49.2",
"sha512crypt-node": "^1.0.2",
"sharp": "^0.33.4",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the sharp library necessary?

Copy link
Member Author

@ayaan-d ayaan-d May 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was just needed for me to be able to deploy locally. I'll remove it from the dependencies.

repoId= {process.env.NEXT_PUBLIC_REPO_ID}
category="Announcements"
categoryId= {process.env.NEXT_PUBLIC_CATEGORY_ID}
mapping="pathname"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this what determines which discussion the comments are placed in?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it creates a thread in the category specified based off of the path like 'blog/hello-world' for example. It might be a good idea to host and pull the comments on a separate repo.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah cool, let's experiment with that in our preview environment in https://github.com/WATonomous/infra-config

@ben-z
Copy link
Member

ben-z commented May 21, 2024

Oh I see, you don't yet have access to the internal repo. Could you fill out the onboarding form and enable the GitHub section and select WATonomous Team? Also, feel free to enable Discord and select the roles Incoming Member and WATcloud.

@ayaan-d ayaan-d closed this May 25, 2024
wato-github-automation bot pushed a commit that referenced this pull request May 25, 2024
Create a React component to be added to blog posts on the website

Closes #2
(Replacement)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants