MicroCMS

A rediculously simple CMS that serves Markdown content files in either an Azure File Share or Blob Container.

No web server needed... no database is used.

This runs as a .NET 6 isolated Azure Function, which means it has a main function that you can inject into at startup just like a web API.

It uses the MarkDig Markdown to HTML converter but you can easily uses any converter you like. All the Advanced Parsing options are turned on so you can add IDs, Classes and even custom attributes to the HTML from the Markdown. This allows you to tweak the layout from the CSS while still using Markdown.

Example

My Test Blog

The Repo

MicroCMS on GitHub

Use Case

I really just wanted a simple way to post Markdown files without having to use someone else's service. Even Jekyll was overkill. Seriously if you think Jekyll is "simple" you are smokin' something. I mean it's cool and all but...

Markdown is much easier and faster to type without all the ridiculous HTML. You can make Markdown as basic or advanced as you like.

Layouts

The concept is pretty simple... Make any HTML template and put it in a templates folder like main.html.

For the body sections just use something like:

<div class="container">
    <div>{% BODY %}</div>
</div>

For now the token must be exactly {% BODY %}. I'm adding more tokens but the only other one for now is 2022-11-21 03:28:34 +00:00.

So browsing to the homepage would be

https://www.myblog.com/page/index?layout=<layout>

For exmaple: Dark Mode Layout

Front Matter

Front matter lets you add Metadata to a Markdown file. As of right now Front Matter is supported and parsed but it's not yet implemented. It's just a YML header at the start of the file like:

---
title: My Title
---

# Welcome to the New World

Endpoints

For now there are only a couple of endpoints :

Getting Started

(More Details Incoming)

Configure the function settings

There are handful of settings you will want to set either in local.settings.json or the Azure Function Configuration:

"Values": {
    "AzureWebJobsStorage": "<Already set in Azure Function>",
    "ASPNETCORE_ENVIRONMENT": "Development",
    "connStr": "Connection String to the Data Storage You want to use",
    "root": "blog",
    "homepage": "index",
    "errorpage": "error",
    "imageDir": "image",
    "layoutDir": "layouts",
    "layoutExt": "html",
    "store": "file"
}

Azure Function Configuration

Local Folder Watcher

There's a second project called Raydreams.MicroCMS.CLI which is an exe that will watch a specific folder on your machine.

You must add the appsettings.json file to your project with similar data as local.settings.json

"AppConfig": {
    "LocalRoot": "",
    "RemoteRoot": "blog",
    "ConnectionString": "",
    "LocalImagesDir": "image",
    "LocalLayoutsDir": "layouts",
    "LocalPagesDir": "page"
}

You can run the exe on OS X using:

dotnet MicroCMS.dll -w <full_path_to_local_blog_root>
dotnet MicroCMS.dll -w "/Users/bob/Desktop/MyBlog/"

On Windows of course you can run just the exe natively itself.

On a file change or addition, the file will be updated remotely. On file deletion or removal, the file will be removed remotely.

Local Structure

To make it easier to preview you Markdown with images you can create a root folder named anything you like

Local Folder Structure:

MicroCMS will only look for images in the image folder. I'm working on this to make it more customizable.

Headless Too

It's even headless. Just addd wrapped=true to the URL.

https://blog.raydreams.com/page/index?wrapped=true

The resulting outer JSON object is not finalized.

Testing

No unit test yet just simple integration test. More to come.