Skip to content

feat: wire DOCUSAURUS_GIT_TOKEN to GitHub service for live discussions#1332

Merged
sanjay-kv merged 4 commits intomainfrom
copilot/dynamic-mapping-for-discussions
Apr 24, 2026
Merged

feat: wire DOCUSAURUS_GIT_TOKEN to GitHub service for live discussions#1332
sanjay-kv merged 4 commits intomainfrom
copilot/dynamic-mapping-for-discussions

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 22, 2026

The Discussions tab always rendered hardcoded mock data because githubService.getHeaders() checked window.GITHUB_TOKEN (never set at runtime), while the actual token was already available in customFields.gitToken (from DOCUSAURUS_GIT_TOKEN env var) — the same pattern statsProvider.tsx uses correctly for leaderboard data.

Changes Made

  • githubService.ts — Added private token field + setToken(token: string) method; updated getHeaders() to prefer stored token, fall back to window.GITHUB_TOKEN
  • dashboard/index.tsx — Added useDocusaurusContext to read customFields.gitToken; calls githubService.setToken() on mount; added a Refresh button (with spin animation) for manual re-fetch; error state now surfaces a direct link to GitHub Discussions when the API call fails
  • discussions.css — Styles for .refresh-discussions-btn, @keyframes spin, and .spinning
  • .env.example — Documented DOCUSAURUS_GIT_TOKEN with required scope (read:discussion)
// dashboard/index.tsx — token wiring
const { siteConfig: { customFields } } = useDocusaurusContext();
useEffect(() => {
  const token = customFields?.gitToken as string;
  if (token) githubService.setToken(token);
}, [customFields?.gitToken]);

When DOCUSAURUS_GIT_TOKEN is set in the deployment environment, the section fetches live discussions via GitHub GraphQL. Without a token, an error with a fallback link to the GitHub Discussions page is shown instead of silent mock data.

Dependencies

No new dependencies.

Checklist

  • My code follows the style guidelines of this project.
  • I have tested my changes across major browsers and devices
  • My changes do not generate new console warnings or errors .
  • I ran npm run build and attached screenshot(s) in this PR.
  • This is already assigned Issue to me, not an unassigned issue.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
recode-website Ready Ready Preview, Comment Apr 22, 2026 6:13am

…m Docusaurus config

- Add setToken() method to GitHubService and update getHeaders() to use the stored token
- Dashboard now reads gitToken from customFields (DOCUSAURUS_GIT_TOKEN env var) and initializes the service before fetching discussions
- Add Refresh button with spinning animation to allow manual re-fetching
- Improve error message to include a direct link to GitHub Discussions
- Update discussions.css with refresh button styles and spin animation
- Update .env.example to document DOCUSAURUS_GIT_TOKEN

Agent-Logs-Url: https://github.com/recodehive/recode-website/sessions/7b2120a4-0104-4379-aa97-06aed89d4a29
Copilot AI changed the title [WIP] Implement dynamic mapping for discussions section feat: wire DOCUSAURUS_GIT_TOKEN to GitHub service for live discussions Apr 22, 2026
Copilot AI requested a review from sanjay-kv April 22, 2026 06:15
@Adez017
Copy link
Copy Markdown
Member

Adez017 commented Apr 22, 2026

so this will require updating the env with GIT_TOKEN along with the docusaurus one

@Adez017
Copy link
Copy Markdown
Member

Adez017 commented Apr 24, 2026

Hi @sanjay-kv could you look into the vercel deployment and let me know if things are working fine ?
ATM its looks good

@sanjay-kv sanjay-kv marked this pull request as ready for review April 24, 2026 08:24
@sanjay-kv sanjay-kv merged commit bc03d65 into main Apr 24, 2026
5 of 7 checks passed
@github-actions
Copy link
Copy Markdown

🎉 Your pull request has been successfully merged! 🎉 Thank you for your valuable contribution to our project.

I would be grateful if you can nominate for keeping this opensource project live and running Link to Nominate. Please do star the repo and Keep up the fantastic work! 🚀

@sanjay-kv
Copy link
Copy Markdown
Member

@Adez017 it looks good in the preview.

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.

💡[Feature]: Use Dynamic mapping for discussions section .

3 participants