You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this article, I'm going to show you how to leverage Github Issues as a CMS, and integrate it into your Next.js blog 🚀
I recently migrated my open-source portfolio website from using Contentful API as a CMS (Content Management System) to GitHub Issues instead.
Here's the detailed PR I made in my portfolio repo to migrate Contentful API to use GitHub Issues if you're interested: abdulrcs/abdulrahman.id#17
Why?
I'm inspired by the blog from swyx.io that uses GitHub issues and comments, as mentioned here.
The friction of writing a GitHub issue is less daunting than using a fully-fledged CMS like Contentful because you have to log in to their page, navigate to the content section, host the images yourself, etc.
This will (hopefully) lead to more writings in the future 🤞
How to use the GitHub API
We can use a GitHub API wrapper using renatorib/github-blog to fetch our GitHub Issues.
Note: GitHub API is limited to 5000 requests/hour, so we need to statically render the blogs using getStaticProps and getStaticPaths to make it scalable, more on that later.
This just made my day, thanks for commenting @swyxio! your blog is what gets me started on the whole idea.
I love how you mentioned my post and it linked our GitHub issue, reminds me of the concept of an interconnected digital garden that you and @MaggieAppleton talked about, so neat!
slug: unleash-your-dev-blog-write-more-with-github-issues-as-your-cms
date: 02-Apr-2024
summary: Turn your GitHub Issues into a powerful Next.js blog to write more and publish faster!
readingTime: 3 min read
image: https://github.com/abdulrcs/abdulrahman.id/assets/54136956/37ce03da-b38f-4e32-84dd-c90636dcc2d6
In this article, I'm going to show you how to leverage Github Issues as a CMS, and integrate it into your Next.js blog 🚀
I recently migrated my open-source portfolio website from using Contentful API as a CMS (Content Management System) to GitHub Issues instead.
Why?
I'm inspired by the blog from swyx.io that uses GitHub issues and comments, as mentioned here.
The friction of writing a GitHub issue is less daunting than using a fully-fledged CMS like Contentful because you have to log in to their page, navigate to the content section, host the images yourself, etc.
This will (hopefully) lead to more writings in the future 🤞
How to use the GitHub API
We can use a GitHub API wrapper using renatorib/github-blog to fetch our GitHub Issues.
First, generate the GitHub token here.
After that, create new labels in your issue named
type:post
,state:published
, andstate:draft
.Then, we can create a GitHub issue for our blog post!
Don't forget to add a front matter in the issue to create a slug for our post URL like this:
Integrating github-blog to Next.js
Installing the Library
Install
@rena.to/github-blog
in your Next.js project.Fetching Lists of Posts
Here's an example of how to fetch a list of posts statically using
getStaticProps
:Fetching a Post using Slug
In the
/blog/[slug]
page, you can query the exact post by using the slug:Generating Static Paths for our posts
We need to statically generate our post URL links by fetching all the posts, and mapping each unique slug inside
getStaticPaths
:Adding Comments Feature
We can use utteranc.es, a lightweight comment widget built on GitHub Issues to integrate authed comments in our blog.
This is brilliant because in a Developer Blog of course there's a big chance that our audience has a GitHub profile 😆
Since we already integrated the GitHub Issues as our blog, we can add comments to our blog by adding this script to our page:
That's it!
I hope that integrating GitHub issues as the source of your posts will empower you to write more consistently and publish faster 🥳
The text was updated successfully, but these errors were encountered: