This is a Next.js-based CMS that allows you to edit markdown files stored in a GitHub repository.
- Node.js 18+ and pnpm
- A GitHub repository with markdown files
- A GitHub Personal Access Token (PAT)
pnpm installUpdate the .env.local file with your configuration:
# Authentication - set your own secure token
LOGIN_TOKEN=your-secure-token-here
# GitHub Configuration
GITHUB_TOKEN=ghp_your_github_pat_here
GITHUB_REPO=username/repository-name
GITHUB_BRANCH=main
GITHUB_FOLDER=content
GITHUB_TARGET_BRANCH=cms-updates
# Public environment variables
NEXT_PUBLIC_GITHUB_FOLDER=contentCreate a GitHub PAT with the following permissions:
- Repository contents: Read & Write
- Repository metadata: Read
To create a PAT:
- Go to GitHub Settings → Developer settings → Personal access tokens → Fine-grained tokens
- Click "Generate new token"
- Select your repository
- Grant the permissions above
- Copy the token to
GITHUB_TOKENin.env.local
pnpm devOpen http://localhost:3000 in your browser.
- Navigate to the app
- Enter the
LOGIN_TOKENvalue you set in.env.local - You'll be redirected to the editor
Session expires after 16 hours.
- File Tree (left pane): Browse and select markdown files
- Editor (middle pane): Edit the raw markdown content
- Preview (right pane): See a live preview in an iPhone 16 frame
- Click the Save button in the top-right corner
- Changes are committed to the
GITHUB_TARGET_BRANCH - If the branch doesn't exist, it will be created automatically
- Commit message: "chore: Update markdown content"
- The editor creates commits on the
GITHUB_TARGET_BRANCHbranch - You must manually review and merge this branch into your main branch
- Unsaved changes trigger a browser warning when navigating away
app/
├── auth/page.tsx # Login page
├── editor/page.tsx # Main editor
└── api/
├── auth/route.ts # Authentication endpoint
└── github/ # GitHub API routes
├── tree/route.ts
├── content/route.ts
└── commit/route.ts
components/
├── auth/LoginForm.tsx
└── editor/
├── EditorLayout.tsx # Main layout
├── FileTree.tsx # File browser
├── MarkdownEditor.tsx # Text editor
├── MarkdownPreview.tsx # Live preview
├── iPhone16Frame.tsx # Mobile frame
├── SaveButton.tsx
└── UnsavedChangesPrompt.tsx
lib/
├── auth/session.ts # Session management
├── github/ # GitHub API integration
│ ├── octokit.ts
│ ├── tree.ts
│ ├── content.ts
│ └── commit.ts
├── store/editorStore.ts # Zustand state
└── utils/
├── cn.ts
└── tree-adapter.ts
- ✅ Simple token-based authentication
- ✅ File tree browser with folder support
- ✅ Live markdown preview with GitHub Flavored Markdown
- ✅ iPhone 16 mobile preview frame
- ✅ Automatic branch creation
- ✅ Unsaved changes warning
- ✅ Session persistence (16 hours)
- Next.js 16 with App Router
- React 19
- TypeScript with strict mode
- Tailwind CSS 4 with Typography plugin
- Zustand for state management
- Octokit for GitHub API
- react-markdown for preview
- react-complex-tree for file browser
- Make sure
.env.localexists and containsGITHUB_TOKEN - Restart the dev server after updating
.env.local
- Check that
GITHUB_REPO,GITHUB_BRANCH, andGITHUB_FOLDERare correct - Verify your GitHub token has correct permissions
- Check that the folder exists in your repository
- The file was updated in GitHub since you opened it
- Refresh the page and try again
- Check your system clock is correct
- Clear localStorage and try logging in again