Version 3.0.0
Breaking changes
Some of the features/changes listed below are from the release of Version 2.0. They are included here for those that are upgrading directly from Version 1.x
Multiple Template Engine Support
The biggest change in this version is support for multiple template engines. As a consequence, Dust.js is now decoupled from Web core and must be included as a dependency on projects that want to use it.
@eduardoboucas has written a handy migration guide for Version 3.0.
Additional template engine plugins will be released at a later date, along with a guide to developing one for your favourite engine, whether it's Pug, Handlebars or Liquid.
Datasource type dadiapi
replaces remote
Previous to Version 2.0 the datasource source type for connecting to a DADI API was called remote
. This has changed to dadiapi
to ensure clarity with the updated and repurposed Remote provider.
A typical datasource specification file would now contain the following:
"source": {
"type": "dadiapi",
"endpoint": "1.0/articles"
}
N.B. The default is dadiapi
, so there is no requirement to specify this property when connecting to a DADI API.
New features
Custom configuration environments
#184: Environments (and configuration files) are no longer limited to production
, development
, test
and qa
.
Inject request parameters into datasource endpoints
You can now pass requestParams
to a datasource endpoint's URL by specifying a new setting "target": "endpoint"
. The param
value will be injected into a placeholder in the URL identified by the field
value. For example:
{
"datasource": {
"key": "instagram",
"source": {
"type": "remote",
"protocol": "http",
"host": "instagram.com",
"endpoint": "{userPlaceholder}/?__a=1"
},
"auth": false,
"requestParams": [
{
"param": "user", // from the request parameters, e.g. http://www.example.com/profile/:user
"field": "userPlaceholder",
"target": "endpoint"
}
]
}
}
Data Providers
Remote Provider
Connect to a miscellaneous API via HTTP or HTTPS. See the following file as an example: workspace/datasources/instagram.json
Markdown Provider
Serve content from a local folder containing text files. You can specify also specify the extension to grab. Web will process any Markdown formatting (with Marked) it finds automatically as well as any Jekyll-style front matter found. Any dates/times found will be processed through JavasScript’s Date()
function.
{
"datasource": {
"source": {
"type": "markdown",
"path": "./workspace/posts",
"extension": "md"
}
}
}
workspace/posts/somefolder/myslug.md
---
date: 2016-02-17
title: Your title here
---
Some *markdown*
When loaded becomes the following data:
{
"attributes": {
"date": "2016-02-17T00:00:00.000Z",
"title": "Your title here",
"_id": "myslug",
"_ext": ".md",
"_loc": "workspace/posts/somefolder/myslug.md",
"_path": [
"somefolder"
]
},
"original": "---\ndate: 2016-02-17\ntitle: Your title here\n---\nSome *markdown*",
"contentText": "Some *markdown*",
"contentHtml": "<p>Some <em>markdown</em></p>\n"
}
NB. _path
will exclude the datasource source.path
.
Virtual Hosts
DADI Web can now serve content to multiple hostnames from a single installation. Only certain configuration options can be modified for each hostname; these are currently restricted to paths
(for pages/partials/datasources/etc) and global
.
"virtualHosts": {
"one": {
"hostnames": ["domain1.dev"],
"configFile": "one.qa.json",
"default": true
},
"two": {
"hostnames": ["domain2.dev"],
"configFile": "two.qa.json"
}
}
Changed
- #98: log more informative error when an event fails