Directus Core is a free and open-source self-hosted platform
published under the GNU (v3) license. It provides a simple and intuitive
web interface for managing database content with completely custom
architectures.
However, what I was planning to do was to create a github repo for my Hugo site and host it from Netlify. Then use any headless CMS to edit content (also someone who has no clue about markdown and frontmatter can edit the content.) after save with a webhook I wanted to trigger Netlify to rebuild my site from the git repo through JSON data.
(BTW netlify has a pretty awesome CMS that works well with Hugo but I would like to create more users and roles.
As I said thanks though.
Edit:
Maybe my question shall be asked this way. How to generate PAGES from JSON data?
I’ve looked at Directus in the past. Seems like it still has a way to go. I really like that Cockpit solution, but haven’t tried it yet. Though I don’t think the core Cockpit is all that actively maintained.
Just throw another one out there: DatoCMS is a headless CMS that will build Hugo pages. It seems to work well and the editor interface is quite good. It’s not open source (though I’ve heard they’re considering it, not sure how true that is). https://www.datocms.com/
Also there are topics about this in the forum. Just search for it. If you don’t find what you need, you probably need to open another thread as this question might be overlooked in here.
var fs = require('fs'); //to access filewrite
var toMarkdown = require ('to-markdown'); //to convert HTML to Markdown
var request = require("request"); //to request the JSON file from the server
var tomlify = require('tomlify'); //to add the frontmatter
//Request options
var options = {
method: 'GET',
json: true,
url: 'YOUR_API_URL',
/* headers:
{ 'cache-control': 'no-cache',
'x-apikey': 'YOUR_API_KEY' }
}; optional */
//Request
request(options, function (error, response, body) {
if (error) throw new Error(error);
var obj = body; //The actual JSON from the API
console.log("Start converting API to files");
//Split up the JSON response
for (var i=0; i<obj.length; i++) {
var toFrontmatter = obj[i];
var htmlstring = obj[i].content; //The content that goes into the Markdown part
var markdowntext = toMarkdown(htmlstring); //The HTML conversion
delete toFrontmatter['_id']; //Deleting the stuff that I do not need to put into the frontmatter
delete toFrontmatter['content']; //Deleting the stuff that I do not need to put into the frontmatter
var obj2 = tomlify(toFrontmatter, {delims: true}); //Creating the frontmatter
obj2 = obj2 +"\n" + markdowntext; //Putting it all togeter
var file = obj[i].slug+'.md'; //I have set up a slug as the file name in my CMS
fs.writeFile(file, obj2, function (err) { //writing it out to the filesystem
if (err) {
console.error(err);
} else {
console.log("Done converting API", obj2);
}
});
}
});`
I use netlify.
I use their Victor-Hugo template. My code lives on bitbucket. Then when someone edits the content on the headless cms (directus, contentful, etc.) through a webhooks i trigger a deploy on netlify.
@mazli84 I have the exact same question as you in this right instant !! You made my day literally. I see you use “Victor-Hugo” instead of “Hugo”, why is that ? Is it necessary to get the workflow to work ?
Finally, I don’t really understand one thing: your node.js code is hosted standalone in some server (OVH, Digital Ocean, OpenShift, Heroku…) that will receive a webhook from your headless CMS ? or is it something hosted right in the “Victor-Hugo” code ?
Wouldn’t it be possible to have a pre-build task that could handle the transformation or something similar ?