Themes
asimov.js doesn’t have a separate “theme API”. A theme is just a plugin that contributes site/templates/, site/styles/, site/scripts/, and site/images/. The same merging rules that apply to plugins apply to themes.
asimov-theme-clean/ index.js package.json site/ templates/ header.tmpl footer.tmpl home.tmpl styles/ main.styl home.stylThe index.js plugin hook is often empty:
module.exports = function plugin () {};module.exports.start = function () { asimov.use(module.exports).start(); };module.parent || module.exports.start();Resolution order
When asimov-static needs site/templates/header.tmpl, it searches in this order, and the first hit wins:
- The current project’s
site/folder. - Each plugin’s
site/folder, in the order they wereasimov.use()d.
This means you can drop in a theme (asimov.use(theme)) and override any individual file by adding it to your own site/templates/.
Theme switching
Because themes are plugins, switching themes is one line in index.js:
var theme = require( process.env.THEME === 'dark' ? 'asimov-theme-dark' : 'asimov-theme-clean');module.exports = function () { asimov.use(theme); };Publishing
A theme is a normal npm package. Convention is to name it asimov-theme-* so it shows up alongside other themes when people search npm.