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

use github access token #825

Merged
merged 4 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Loading