fles / myblog Goto Github PK
View Code? Open in Web Editor NEWHome Page: https://myblog-silk-delta.vercel.app/
Home Page: https://myblog-silk-delta.vercel.app/
In this article, I will show how to create your own developer-focused blog that lets you publish your own posts by creating an issue on GitHub. You don't have to sign up for anything or even log in. Just create an issue and that's your first post.
Since it's backed by GitHub issues, anybody with a GitHub account can add a comment or reaction to your post and you'll get a notification through the GitHub notification system that you're already familiar with.
If you ever want to move your content to a different platform, you can export all of your data in full fidelity as markdown or HTML.
Issues are fetched from GitHub using OneGraph's persisted GraphQL queries. Persisted queries are an underutilized GraphQL feature with many benefits over plain queries. The benefit that makes them well-suited for our use-case is that we can attach metadata to the query.
GitHub doesn't allow unauthenticated queries, so we attach a default auth to the query when we persist it. We also tell OneGraph to only allow requests for issues from the digitalblog repo and to cache the results of the query for 5 minutes so that we don't blow through our rate limit. You can read more about persisted queries in the OneGraph docs.
We use the wildcard domains support from Vercel and next.js to determine the author from the subdomain. The first part of the subdomain tells us which GitHub user's issues to fetch.
Prerequests:
To host your content yourself or on your own domain, there's a Vercel button for that.
Open OneGraph to create a new app (or rename the existing one).
Generate 2 tokens on OneGraph:
a) Auth Services > Server-side > Personal token > Create personal Token
b) Persisted Queries > Your API Tokens for Persisting Queries > Create Token
Setup project environment variables (Vercel)
Environment Variable | Description |
---|---|
OG_GITHUB_TOKEN |
A server-side access token created on OneGraph, used as the default auth for the persisted queries that will fetch the issues. To create a new one, go the "Server-side Auth" tab in the OneGraph dashboard for your app, click the "Create Token" button, and add GitHub to the services. Keep this token safe, because it has access to your GitHub data. |
OG_DASHBOARD_ACCESS_TOKEN |
An API token that allows you to create persisted queries on OneGraph. Go to the "Persisted queries" tab on the OneGraph dashboard, scroll down, and click "Create token". This will create a scoped token for your app that can create persisted queries on your behalf. |
NEXT_PUBLIC_ONEGRAPH_APP_ID |
The id of your OneGraph app. You can get this from the OneGraph dashboard |
NEXT_PUBLIC_TITLE |
The title of your site |
After that, Vercel will deploy your blog (you can find the link on your Vercel dashboard).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.