Skip to content

Commit

Permalink
Merge pull request #825 from ai16z/tcm-docusaurus-env
Browse files Browse the repository at this point in the history
use github access token
  • Loading branch information
tcm390 authored Dec 3, 2024
2 parents 1470fdc + 80d3b3c commit 88e90a9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
10 changes: 10 additions & 0 deletions docs/community/Contributions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useState, useEffect } from "react";
import { Accordion } from "./Accordion";
import { StatCard } from "./StatCard";
import { THEME_COLORS } from "./Contributors";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";

export interface GitHubItem {
html_url: string;
Expand All @@ -26,6 +27,9 @@ const initializeAccordionItem = (): AccordionItem => ({
});

const Contributions = ({ contributor, onBack, darkMode }) => {
const { siteConfig } = useDocusaurusContext();
const { GITHUB_ACCESS_TOKEN } = siteConfig.customFields;

const [commitsData, setCommitsData] = useState<AccordionItem>(
initializeAccordionItem(),
);
Expand Down Expand Up @@ -64,7 +68,9 @@ const Contributions = ({ contributor, onBack, darkMode }) => {
const commitResponse = await fetch(
`https://api.github.com/repos/ai16z/eliza/commits?author=${contributor.login}&page=${page}`,
{
method: "GET",
headers: {
Authorization: `token ${GITHUB_ACCESS_TOKEN}`,
Accept: "application/vnd.github.v3+json",
},
},
Expand All @@ -90,7 +96,9 @@ const Contributions = ({ contributor, onBack, darkMode }) => {
const prResponse = await fetch(
`https://api.github.com/search/issues?q=type:pr+author:${contributor.login}+repo:ai16z/eliza&page=${page}`,
{
method: "GET",
headers: {
Authorization: `token ${GITHUB_ACCESS_TOKEN}`,
Accept: "application/vnd.github.v3+json",
},
},
Expand All @@ -116,7 +124,9 @@ const Contributions = ({ contributor, onBack, darkMode }) => {
const issueResponse = await fetch(
`https://api.github.com/search/issues?q=type:issue+author:${contributor.login}+repo:ai16z/eliza&page=${page}`,
{
method: "GET",
headers: {
Authorization: `token ${GITHUB_ACCESS_TOKEN}`,
Accept: "application/vnd.github.v3+json",
},
},
Expand Down
11 changes: 11 additions & 0 deletions docs/community/Contributors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useEffect, useState, useRef } from "react";
import ContributorCard from "./Contributor";
import Contributions from "./Contributions";
import { useColorMode } from "@docusaurus/theme-common";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";

export interface Contributor {
id: number;
Expand Down Expand Up @@ -33,6 +34,9 @@ export const THEME_COLORS = {
};

const Contributors: React.FC = () => {
const { siteConfig } = useDocusaurusContext();
const { GITHUB_ACCESS_TOKEN } = siteConfig.customFields;

const { colorMode } = useColorMode();
const [selectedContributor, setSelectedContributor] =
useState<Contributor | null>(null);
Expand All @@ -54,6 +58,13 @@ const Contributors: React.FC = () => {
try {
const response = await fetch(
`https://api.github.com/repos/ai16z/eliza/contributors?per_page=30&page=${page}`,
{
method: "GET",
headers: {
Authorization: `token ${GITHUB_ACCESS_TOKEN}`,
Accept: "application/vnd.github.v3+json",
},
},
);
if (!response.ok) {
throw new Error(
Expand Down
8 changes: 7 additions & 1 deletion docs/docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { themes as prismThemes } from "prism-react-renderer";
import dotenv from "dotenv";

dotenv.config();

const config = {
title: "eliza",
Expand Down Expand Up @@ -218,6 +221,9 @@ const config = {
darkTheme: prismThemes.dracula,
},
},
customFields: {
GITHUB_ACCESS_TOKEN: process.env.GITHUB_ACCESS_TOKEN,
},
};

export default config;
export default config;

0 comments on commit 88e90a9

Please sign in to comment.