Github Issues as CMS

2022-01-19


Previously i saw tweets by swyx that he is building a blog starter project called swyxkit. It is basically a blog starter built using SvelteKit + Tailwind + Netlify. One special thing about the project is it is using Github Issues as CMS for blog posts.

There are some benefits of using Github as CMS:

  • Store images easily (copy-pasting from clipboard)
  • Available comment system

This seems pretty convincing and I pretty like the idea as well. So.... I decided to try it myself.

Currently, I am using hashnode for hosting my blog post. It is pretty good. But yeah, just wanna try this out.

How to?

Github has a graphql API that allows us to query repository details easily. I am using the GitHub GraphQL API client library by octokit (here) to query the repository issues and display them on my personal website as blog posts.

It is pretty straightforward as the documentations are pretty clear and simple for using @octokit/graphql.

To understand what are the objects available, I explore the GitHub API to obtain fields that available and required for me to display the blog posts and comments.

Problems

As each issue are indexed with ID (eg. 1,2,3,4), it is not ideal to use it as a slug for the blog post. Therefore, I have to add in frontmatter within the markdown file to add metadata such as title, description, and also slug for the blog post.

Results

The results are now on my personal website!! Give me drop a reaction to the GitHub issues if you like them!!!. The repository is open for everyone to have a look into the source code.

Reactions: 0 ❤️View on Github

No Comments Now