Tutorials
Last Updated:
September 2019
Publish is the content management component of the DADI web services stack, a set of flexible interfaces to easily manage content stored in API.

Tutorials
Last Updated:
September 2019


We abstracted the template engine in Web 3.0, opening the doors for people to hook in any engine they wish.
Publish is the content management component of the DADI web services stack, a set of flexible interfaces to easily manage content stored in API. This post gives an overview of setting it up and connecting to a DADI API instance.
We should note that many of the core web services in the DADI platform can be installed very simply using the DADI CLI tool. Publish is still in a public beta phase and doesn't yet benefit from CLI's simplified install process.
$ mkdir ~/projects/publish-cms
$ cd ~/projects/publish-cms~/projects/publish-cms/package.json
{
"name": "publish-cms",
"version":
server.js, which we'll use for launching the application:~/projects/publish-cms/server.js
const app = require('@dadi/publish')
app.run()@dadi/publish dependency, running npm install now will install everything you need: $ npm installWhen installation completes, you're ready to start the application.
Now that the application is installed, we're going to configure it to connect to an instance of DADI API.
If you have your own instance of API running, use that in the below configuration of Publish. If you don't have an API running yet, head to the API documentation for more information, or check out the Adam K Dean's article on setting up a photo gallery website where he briefly explains API installation. In a future article, we'll be covering "Installing API with CLI and setting up collections".
config directory in your Publish directory to contain the configuration files for the application:config directory create a configuration file for the development environment called config.development.json. Add the following:~/projects/publish-cms/config/config.development.json
{
"app": {
"name": "My CMS",
"publisher": "My Publishing Company"
},
"server": {
"host": "0.0.0.0",
"port": 3001,
},
"apis": \\\[
{
"name": "Test API",
"host": "http://localhost",
"port":
npm start again. If your API already contains collections and content you should see a menu and document list similar to the below:
By default all collections and collection fields from your API are visible and editable within Publish. To hide collections and/or fields within collections, see below.
API collection schemas allow custom properties that can be read by Publish to modify the editing interface.
Add a publish configuration block to each field in your API collection schemas to control how they appear in Publish:
{
"fields": {
"title": {
"type": "String",
"required": true,
"label": "Title",
"publish": {
"display": {
"edit": true, // field will appear in the edit view
"list": false // field will not appear in the index view
}
}
}
}
}Hide a collection by adding hidden to the collection settings block:
{
"fields": {
"field1": {
},
"field2": {
},
},
"settings": {
"publish": {
"hidden": true
}
}
}This post has only just scratched the surface of what is possible with DADI Publish. In a future article, we'll go into more detail about setting up authentication for Publish so you can control access to your content management system.
If you want to know more about how Publish can elevate the potential of your editorial team, ask me here, on Discord or tweet @dadi.