Overview
The MilesONerd blog system is a serverless, client-side blog that fetches Markdown files directly from GitHub and renders them dynamically using Showdown.js. This approach eliminates the need for a backend server while maintaining full version control through Git.The blog uses the GitHub API to fetch Markdown files from the repository, converting them to HTML on-the-fly for display.
Key Features
Serverless Architecture
No backend required - all content is served directly from GitHub
Markdown Support
Full Markdown syntax with Showdown.js conversion
Git Version Control
Blog posts are managed as Markdown files in the repository
Dynamic Loading
Posts load asynchronously without page refreshes
How It Works
The blog system consists of two main functions that work together to fetch and display content:Fetch Post List
The
fetchPostList() function queries the GitHub API to retrieve all Markdown files from the /old/blog/posts directory.Load Post Content
When a user clicks a post link,
loadPostContent() fetches the raw Markdown and converts it to HTML.Implementation
Configuration
The blog system is configured to point to the GitHub repository:The
showdown.Converter() instance is created globally to be reused for all Markdown conversions.Fetching the Post List
ThefetchPostList() function retrieves all blog posts from GitHub:
How the GitHub API Request Works
How the GitHub API Request Works
The function constructs a URL to the GitHub API’s
/contents endpoint, which returns metadata about all files in the specified directory. The response includes:- File names
- Download URLs for raw content
- File sizes and types
.md are filtered and displayed as blog posts.Loading Post Content
When a user clicks a post, theloadPostContent() function retrieves and renders it:
Initialization
The blog automatically loads the post list when the script runs:Blog Post Structure
Blog posts are stored as Markdown files in the/old/blog/posts/ directory. Here’s an example structure:
Advantages
Zero Server Costs
Hosting is free via GitHub Pages with no backend infrastructure
Version Controlled
Every blog post edit is tracked in Git history
Easy Content Management
Write posts in any text editor using simple Markdown syntax
Fast Performance
Client-side rendering keeps the blog lightweight and responsive
Error Handling
The system includes comprehensive error handling for both API failures and content loading issues:Dependencies
The blog system requires two external libraries:- Showdown.js - Markdown to HTML converter
- GitHub API - Content delivery and file listing
File Location
The complete blog system implementation can be found at:~/workspace/source/old/blog/scripts/list-posts.js
The blog was part of the original milesonerd.github.io site and has been preserved in the
/old/ directory of the current site.