This way, we are able to review new blog posts without re-deploy
Github provides a solution to retrieve data through REST API
How to parse front-matter
Installation front-matter
Transforming Markdown to HTML
Custom React Markdown
Simply follow the official guide to custom React Markdown
Syntax Highlighting
Shiki Highlighting + Cloudflare Worker bundle small
A Worker can be up to 10 MB in size after compression on the Workers Paid plan, and up to 1 MB on the Workers Free plan
But if using Shiki the build folder size also increase from ~1MB to ~10MB, you could not deployed that current release to Worker if you’re using Free Plan
✘ [ERROR] Failed to publish your Function. Got error: Your Functions script is over the 1 MiB size limit (workers.api.error.script_too_large)
To resolve it, we should load the Shiki Script from esm.sh, which helps reduce the build folder size because of skipping Shiki.
Fetching multiple Markdown Files
Usually, you want to display a list of all your content to users as well. GitHub offers an API endpoint to get all files within a directory. From there, we can fetch each file content and parse the frontmatter. This should give us all the information required to render a list of contents.
Caching Response Github
GitHub throttles the number of requests you can make to their API. To avoid this, we can cache the responses from GitHub. If you’re using Cloudflare Worker, you can use KV Namespaces to cache its