2017 Oct, Mon 23

Creating an awesome blog with headless cms

Sun Sep 3 14:05:08 CEST 2017

Woop, first post. About this blog. I wanted to make a blog but was thinking that Drupal is to old and heavy, and I wanted to try out a headless CMS. So I picked this small CMS that only has a admin interface and a simple REST api. The headless CMS which I'm trying out is called Cockpit, it took quite a bit of effort to get this working with my current setup.

So, Why would I want a headless CMS? Well, I like to use Javascript and it makes it easier to get data for my compoents later on. Cockpit also has a collection system which makes it easier to make more custom content types.

But it required lots of reading issues on Github and grepping code and experimenting with the api to understand what features exists under the hood. It does not exist a lot of documentation currently for Cockpit which makes it a bit more challenging. But reading old issues and doing old school tinkering is pretty refreshing when you get some results that finally works.

This is what I discovered so far:

/api/collections/get/posts/?[params]

params: {
    token: apikey
    sort: {"my_field": "-1"} // (DESC = -1, ASC = 1)
    filter: {"title_slug": "my-article-slug-key"}
    limit: integer
    skip: integer // aka offset
    populate: (unknown) // not sure yet what this does
}

The params goes to MongoLite library which is a wrapper around sqlite3, so we have schemaless sqlite, pretty cool. The fields gets defined in the collection gui in the adminpanel, where you can add different panel types and inputs.

To get the slugs working you need to add a options object to your input field in the admin panel. Which takes JSON like this:

{
    "slug": "true"
}

There is a lot more options hidden, now I just need to figure out how the get github flavoured markdown.

Thats about it for now. Check the links below if curious about the cms.

Cockpit@Github

MongoLite@Github

Random widget