0.3.0 • Published 7 years ago
metalsmith-marko v0.3.0
metalsmith-marko
A Metalsmith plugin to render files with Marko templates.
It supports rendering source files with templates and layouts. By default it looks for layout files in layouts
directory. You need to set the layout
in source file frontmatter section in order to render it in a layout. Optionally, you can set defaultLayout
in plugin options.
Installation
$ npm install metalsmith-marko
Usage
Without Options
let marko = require("metalsmith-marko")
metalsmith.use(marko())
With Options
let marko = require("metalsmith-marko")
metalsmith.use(marko({
layoutsDirectory: "layouts",
defaultLayout: "default.html",
pattern: ["**/*.marko", "**/*.html"],
compilerOptions: {
writeToDisk: false,
preserveWhitespace: true
}
}))
Default Options
layoutsDirectory: "layouts",
pattern: ["**/*.marko"],
compilerOptions: {
writeToDisk: false,
preserveWhitespace: true
}
Templates
layouts/default.html.marko
<!DOCTYPE html>
<html>
<head>
<title>${data.title}</title>
</head>
<body>
$!{data.contents}
</body>
</html>
pages/index.html.marko
<article>
<h1>Heading</h1>
<div for(page in data.pages)>${page.title}</div>
</article>