A Minimum Viable Product (MVP) for a blog website using GitHub as a CMS and Next.js for Static Site Generation (SSG).
This blog uses a GitHub repository as the Content Management System (CMS), managed via the GitHub REST API. It leverages Next.js Static Site Generation (SSG) to build the public-facing site from Markdown files stored in the repository.
- Unauthenticated admin interface for writing blog posts
- "Publish" button that uses GitHub REST API to commit Markdown files to the repository
- Public-facing blog pages built using Next.js SSG
- Ready for easy deployment to Vercel
github-blog-mvp/
├── _posts/ # Directory where blog posts are stored as markdown files
├── components/ # React components
│ ├── AdminForm.tsx # Form for creating new posts
│ ├── Layout.tsx # Layout wrapper with header and footer
│ └── PostList.tsx # Component to display list of posts
├── lib/ # Utility functions
│ ├── github.ts # GitHub API integration
│ └── posts.ts # Functions to work with markdown files
├── pages/ # Next.js pages
│ ├── _app.tsx # Custom App component
│ ├── admin.tsx # Admin interface for writing posts
│ ├── blog/
│ │ └── [slug].tsx # Dynamic route for individual blog posts
│ ├── api/
│ │ └── publish.ts # API endpoint for publishing posts to GitHub
│ └── index.tsx # Blog home page / post listing
├── styles/ # CSS styles
│ └── globals.css # Global styles and Tailwind imports
├── .env.example # Example environment variables
├── .gitignore # Git ignore file
├── next.config.js # Next.js configuration
├── package.json # Project dependencies and scripts
├── postcss.config.js # PostCSS configuration for Tailwind
├── tailwind.config.js # Tailwind CSS configuration
└── tsconfig.json # TypeScript configuration
- Node.js 14+ and npm
- A GitHub account with a repository for storing blog posts
-
Clone this repository:
git clone https://github.com/your-username/github-blog-mvp.git cd github-blog-mvp -
Install dependencies:
npm install -
Edit the GitHub configuration in
lib/github.ts:// Replace these with your own values const GITHUB_TOKEN = 'your_github_personal_access_token'; const GITHUB_REPO_OWNER = 'your_github_username'; const GITHUB_REPO_NAME = 'github-blog-mvp'; const GITHUB_FILE_PATH = '_posts';
-
Run the development server:
npm run dev -
Open http://localhost:3000 in your browser.
- Navigate to http://localhost:3000/admin to access the admin interface.
- Create a new post by filling out the form and clicking "Publish".
- The post will be committed to your GitHub repository.
- When deployed on Vercel, trigger a new build to generate the static pages including your new post.
This project is ready for deployment on Vercel:
- Push your code to GitHub
- Connect your repository to Vercel
- Configure the necessary environment variables
- Deploy!
- This is a test/MVP project with an unauthenticated admin interface. In a production environment, you would want to add authentication.
- The admin interface publishes posts directly to your GitHub repository.
- To see new posts on the live site after publishing, you need to trigger a new build on Vercel.