An Astro project that serves as a CMS backend for GitHub discussions from the Kilo community.
- GitHub Discussions API: Server-side API endpoint that fetches discussions from the "built-with-kilo" category
- Vercel Deployment: Configured for serverless deployment on Vercel
- TypeScript Support: Full TypeScript support with proper type definitions
- Caching: API responses are cached for 5 minutes to improve performance
-
Install dependencies:
pnpm install
-
Configure GitHub Token:
- Copy
.env.example
to.env
- Create a GitHub Personal Access Token at https://github.com/settings/tokens
- Required scopes:
public_repo
(for accessing public repositories) - Add your token to the
.env
file:GITHUB_TOKEN=your_github_token_here
- Copy
-
Development:
pnpm dev
-
Build for production:
pnpm build
Fetches GitHub discussions from the "built-with-kilo" category.
Query Parameters:
limit
(optional): Number of discussions to fetch (default: 10, max: 100)after
(optional): Cursor for pagination (usepageInfo.endCursor
from previous response)
Response:
{
"discussions": [
{
"id": "string",
"title": "string",
"body": "string",
"bodyHTML": "string",
"url": "string",
"createdAt": "string",
"updatedAt": "string",
"author": {
"login": "string",
"avatarUrl": "string",
"url": "string"
},
"category": {
"id": "string",
"name": "string",
"slug": "string"
},
"labels": {
"nodes": [
{
"id": "string",
"name": "string",
"color": "string"
}
]
},
"reactions": {
"totalCount": 0
},
"comments": {
"totalCount": 0
}
}
],
"pageInfo": {
"hasNextPage": false,
"endCursor": "string"
},
"total": 0
}
Example Usage:
// Fetch first 5 discussions
const response = await fetch('/api/discussions?limit=5');
const data = await response.json();
// Pagination
const nextPage = await fetch(`/api/discussions?limit=5&after=${data.pageInfo.endCursor}`);
Visit /test-api
in your browser to test the API endpoint with a simple interface.
This project is configured for Vercel deployment:
- Connect your repository to Vercel
- Set the
GITHUB_TOKEN
environment variable in your Vercel project settings - Deploy!
The API will be available at https://your-domain.vercel.app/api/discussions
src/
├── pages/
│ ├── api/
│ │ └── discussions.ts # GitHub discussions API endpoint
│ ├── test-api.astro # API testing page
│ └── index.astro # Main page
├── components/ # React/Astro components
├── layouts/ # Page layouts
└── styles/ # Global styles
GITHUB_TOKEN
: GitHub Personal Access Token withpublic_repo
scope
- Astro: Static site generator with server-side rendering
- React: UI components
- TypeScript: Type safety
- Tailwind CSS: Styling
- Vercel: Deployment platform
- GitHub GraphQL API: Data source