Skip to content

Metalsmith plugin to render files with Marko templates

License

Notifications You must be signed in to change notification settings

steverandy/metalsmith-marko

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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>

License

MIT License

About

Metalsmith plugin to render files with Marko templates

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published