TURING HUT # GitHub Events/Newsletters Admin
A Next.js-based admin interface for managing events and newsletters stored in GitHub repositories. This application allows you to create, edit, and delete markdown files directly from a web interface, with all changes submitted via Pull Requests.
For the Turing Hut website, use these configuration values:
- Base Repository Path:
linustribevnr/turing-hut-website
- Target Folder Path:
src/assets/events - Image Path:
src/assets/images/events
- Target Folder Path:
src/assets/newsletters - Image Path:
src/assets/images/newsletters
- π GitHub PAT Authentication - Secure authentication using Personal Access Tokens
- π CRUD Operations - Create, Read, Update, and Delete files
- ποΈ Live Preview - Real-time markdown preview while editing
- π Pull Request Workflow - All changes are submitted via PRs for review
- π Table View - Clean table interface to view all files
- π― Configurable Paths - Support for custom repository and folder paths
- π― No Environment Variables - Each user provides their own PAT and paths on page load
- Node.js 18+ installed
- A GitHub account with repository access
- A GitHub Personal Access Token with
reposcope
- Clone this repository:
git clone <your-repo-url>
cd Turing-hut-event-admin- Install dependencies:
npm install- Run the development server:
npm run dev- Open http://localhost:3000 in your browser
- Go to GitHub Settings β Developer settings β Personal access tokens β Tokens (classic)
- Click "Generate new token (classic)"
- Give it a descriptive name (e.g., "Events Admin")
- Select the
reposcope (full control of private repositories) - Click "Generate token"
- Copy the token (you won't be able to see it again!)
-
On the application homepage, you'll see form fields for:
- GitHub Personal Access Token: Paste your PAT here
- Base Repository Path: Enter the repository path (e.g.,
owner/repo) - Target Folder Path: Path where markdown files will be stored
- Image Path: Path where uploaded images will be stored
-
For Turing Hut website, use the configuration values listed above
-
Click "Authenticate"
- All files are displayed in a table format
- You can see the filename, path, and a preview of the content
- Click "Add File" button
- Enter a filename (
.mdextension will be added automatically if not provided) - Edit the markdown content in the editor
- Optionally upload an image
- Use the live preview to see how it will look
- Click "Create (Create PR)" to submit a pull request
- Click "Edit" button next to any file
- Modify the content in the editor
- Optionally change or upload a new image
- Use the live preview to verify changes
- Click "Update (Create PR)" to submit a pull request
- Click "Delete" button next to any file
- Confirm the deletion
- The file will be deleted directly (no PR created for deletions)
app/
βββ components/
β βββ EventsTable.jsx # Table component for listing files
β βββ EventEditor.jsx # Editor component with live preview
β βββ Toast.jsx # Toast notification component
β βββ ConfirmDialog.jsx # Confirmation dialog component
βββ globals.css # Global styles including markdown prose
βββ layout.jsx # Root layout
βββ page.jsx # Main page with authentication and routing
- Authentication: Uses Octokit to authenticate with GitHub using the provided PAT
- Configuration: User provides repository path, target folder, and image folder paths
- Read Files: Fetches markdown files from the specified directory using GitHub API
- Edit/Add: Creates a new branch, commits changes, uploads images, and opens a PR
- Delete: Directly deletes the file from the repository
- Live Preview: Uses react-markdown to render markdown content in real-time
- Image Upload: Supports uploading images which are automatically linked in markdown
- Next.js 15 - React framework with App Router
- Octokit - GitHub REST API client
- React Markdown - Markdown rendering for live preview
- Tailwind CSS - Utility-first CSS framework
- Gray Matter - Parse markdown frontmatter (available if needed)
- PATs are stored only in browser memory and never sent to any server except GitHub
- Each user must provide their own PAT
- All changes are made through PRs, allowing for review before merging
- Recommend using fine-grained PATs with minimal necessary permissions
Edit the default template in app/components/EventEditor.jsx:
setContent(`---
title: "Your Custom Title"
// ... your custom frontmatter
---
# Your Custom Content
`);Modify the prose styles in app/globals.css to customize how the markdown renders.
- Verify your PAT is correct and has the
reposcope - Check if the token has expired
- Verify the repository owner, name, and path are correct
- Ensure your PAT has access to the repository
- Check that the target directory exists
- Ensure you have write access to the repository
- Check if there are no conflicting branch names
- Verify the repository allows PR creation
- Check that the image path is correct
- Ensure your PAT has write permissions
- Verify image file size is reasonable (GitHub has limits)
Feel free to submit issues and enhancement requests!
MIT