cache github article list in next.js.
import { createSource } from "git-mdx-loader";
const source = createSource({
owner: "your-github-user",
repo: "your-articles-repo",
folder: "articles",
token: process.env.GITHUB_TOKEN,
revalidateSeconds: 300,
debug: true,
});
const articles = await source.listEntries();
const article = await source.getEntry("hello-world");createSource(options)source.listEntries()source.getEntry(slug)RenderContent
owner: github ownerrepo: github repo namefolder: folder with.mdfilestoken: github token for private reposref: branch, tag, or commitapiBaseUrl: custom github api urlfetch: custom fetch functionrevalidateSeconds: cache ttl in seconds, usefalsefor foreverdebug: print short server logs
slugpathfilenamecontentfrontmatter- frontmatter parse is simple yaml-like fields only
import { RenderContent } from "git-mdx-loader";
<RenderContent content={entry.content} />- set
cachecomponents: trueinnext.config.js - next.js 15 and 16 app router and server components only
- no markdown render here
- no update, delete, or webhook
- github list stored in next cache
[github-md] listEntries[github-md] listEntries[github-md] fetch GitHub directory[github-md] getEntry:hello-world[github-md] fetch GitHub file: hello-world.md[github-md] source unavailable: listEntries[github-md] source unavailable: hello-world.md