https://github.com/sinanbekar/next-github-source
[WIP] Use GitHub repo as CMS in Next.js (similar Hashnode's Github as source)
https://github.com/sinanbekar/next-github-source
cms markdown nextjs typescript
Last synced: about 2 months ago
JSON representation
[WIP] Use GitHub repo as CMS in Next.js (similar Hashnode's Github as source)
- Host: GitHub
- URL: https://github.com/sinanbekar/next-github-source
- Owner: sinanbekar
- License: mit
- Created: 2022-10-22T20:07:33.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-23T15:28:28.000Z (over 3 years ago)
- Last Synced: 2025-10-05T05:24:04.491Z (9 months ago)
- Topics: cms, markdown, nextjs, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/next-github-source
- Size: 50.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# next-github-source
Use GitHub repo as CMS in Next.js (similar Hashnode's Github as source)
> **Warning** This package is early in development. Do NOT use in production environment.
## 🚀 Quick Start
```bash
npm install next-github-source
```
`lib/githubSourceClient.js`
```js
import { createClient } from "next-github-source";
export const client = createClient({
repo: {
remote: `https://github.com/Hashnode/Hashnode-source-from-github-template`,
},
pattern: [`**`, "!README.md"], // list all except README.md
});
```
`pages/index.js`
```js
import Link from "next/link";
import { client } from "../../lib/githubSourceClient";
export const getStaticProps = async () => {
const posts = await client.getAllEntries();
return {
props: { posts },
};
};
export default function Posts({ posts }) {
return (
);
}
```
`pages/posts/[slug].js`
```js
import { client } from "../../lib/githubSourceClient";
export const getStaticPaths = async () => {
return {
paths: await client.getAllEntryPaths(),
fallback: false,
};
};
export const getStaticProps = async ({ params }) => {
const post = await client.getEntry(params.slug);
return {
props: { post },
};
};
export default function Post({ post }) {
return
{JSON.stringify(post)};
}
```
## TODO
- [ ] Examples with `next-mdx-remote`
- [ ] On-demand revalidation support with examples
- [ ] Matter support with types & validation
- [ ] High test coverage
- [ ] Docs
## License
[MIT](./LICENSE) License © 2022 [Sinan Bekar](https://github.com/sinanbekar)