@type param1 param2
@otherType: Content{
type: 'type',
params: ['param1', 'param2'],
content: [
{
type: 'otherType',
params: [],
content: ['Content']
}
]
}function identityTransform (file) {
return file
}const path = require('path')
// The htmlRenamer from 'quantum-html'
// renames name.html to name/index.html and leaves index.html as it is
function htmlRenamer () {
return (file) => {
if (path.extname(file.info.dest) === '.html') {
const filenameWithoutExtension = path.basename(file.info.dest).replace('.html', '')
const rootPath = path.dirname(file.info.dest)
return file.clone({
info: file.info.clone({
dest: filenameWithoutExtension === 'index' ? file.info.dest : path.join(rootPath, filenameWithoutExtension, 'index.html')
})
})
} else {
return file
}
}
}@type param1 param2: Content@ denotes the start of a new entity. {
type: 'type',
params: ['param1', 'param2'],
content: ['Content']
}type params and content @type param1 param2params is: ['param1', 'param2']@ type of the entity, e.g for @code the type is 'code' const dom = require('quantum-dom')
function notice (selection, transformer) {
return dom.create('div').class('notice')
.add(dom.create('div').class('notice-header').text(selection.ps()))
.add(dom.create('div').class('notice-body').add(selection.cs()))
}@notice Warning: There is something you should know<div class="notice">
<div class="notice-header">Warning</div>
<div class="notice-body">There is something you should know</div>
</div>function customTransform (selection, transformer) {
return dom.create('div').class('custom-class')
// Transform the content of the selection
.add(selection.transform(transformer))
}quantum-dom and quantum-html modules: const dom = require('quantum-dom')
// creates a sign in block for the @signIn entity
function signIn (selection) {
return dom.create('div').class('sign-in')
.add(dom.create('input').class('username-input'))
.add(dom.create('input').class('password-input'))
.add(dom.create('button').class('sign-in-button').text('Sign in'))
}
function entityTransforms () {
return Object.freeze({
signIn
})
}
module.exports = {
entityTransforms
}const custom = require('./custom.js')
const html = require('quantum-html')
const htmlOptions = {
entityTransforms: {
custom: custom.entityTransforms()
}
}
module.exports = {
pipeline: [
html(htmlOptions)
],
pages: 'index.um'
}@signInquantum build would render the index.um pageand output to target/index.html<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1"></meta>
</head>
<body class="qm-body-font">
<!-- the result of the @signIn transform -->
<div class="sign-in">
<input class="username-input"></input>
<input class="password-input"></input>
<button class="sign-in-button">Sign in</button>
</div>
</body>
</html>