Mecha CMS

Custom site appearance.

Layout-Less

Table of Contents
  1. Usage 
  2. Supported Parameters 
  3. URL Examples 
  4. JavaScript Example 

A layout system that outputs JSON data instead of HTML page. Useful for those who want to use Mecha as a headless CMS.

Download Version 1.0.0 Download Development Version

Something looks broken? We accept bounties to fix them faster.

A headless CMS is a back-end only content management system built from the ground up as a content repository that makes content accessible via a RESTful API for display on any device. The term “headless” comes from the concept of chopping the “head” (the front end, i.e. the website) off the “body” (the back end, i.e. the content repository).

Usage 

Accessing regular page URL will produce a JSON output, so you can process that using third-party services. The output will be cached for a day unless you add a ?cache=0 parameter to the URL. The following is an example output of a single page:

{
  "status": 200,
  "t": "Page Title | Site Title",
  "generator": "Mecha 2.2.1",
  "url": {
    "next": "https://mecha-cms.com/article/page-name-2",
    "prev": null,
    "self": "https://mecha-cms.com/article/page-name"
  },
  "title": "Site Title",
  "description": "Site description.",
  "can": { … },
  "are": { … },
  "has": { … },
  "is": {
    "page": true,
    …
  },
  "not": { … },
  "page": {
    "id": "1577813996",
    "title": "Page Title",
    "description": "Page description.",
    "time": "2020-01-01 00:39:56",
    "link": null,
    "url": "https://mecha-cms.com/article/page-name",
    "x": "page"
  }
}

Supported Parameters 

NameDescription
cacheSet to a value that can be evaluated to false to disable the cache.
tokenTODO: Make your data private by adding a mandatory access token.
siteList your properties (separated by commas) that you want them to be available in the JSON output, taken from the $site variable.
pageList your page properties (separated by commas) that you want them to be available in the JSON output.
pagesList your page properties (separated by commas) of the pages that you want them to be available in the JSON output.
tagList your tag properties (separated by commas) that you want them to be available in the JSON output.

URL Examples 

https://mecha-cms.com/article/1?page=title,description,content,time&pages=title,description,time,url,link
https://mecha-cms.com/article/page-name?page=title,description,time,content

JavaScript Example 

<script>
fetch('https://mecha-cms.com/article/page-name').then(response => {
    if (!response.ok) {
        // …
    }
    return response.json();
}).then(json => {
    console.log(json);
});
</script>