Last active
December 1, 2016 15:44
-
-
Save jhyland87/4f0a1c04683ac4e8cea84afa6063dc93 to your computer and use it in GitHub Desktop.
include() BEFORE & AFTER layouts()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Metalsmith = require('metalsmith'); | |
const layouts = require( 'metalsmith-layouts' ) | |
const markdown = require('metalsmith-markdown') | |
const include = require('metalsmith-include') | |
const config = { | |
source: 'src', | |
buildPath: 'public' | |
} | |
Metalsmith(__dirname) | |
.source( config.source ) | |
.destination( config.buildPath ) | |
.clean(true) | |
.use(markdown({ | |
html: true, | |
xhtmlOut: true, | |
typographer: true, | |
linkify: true | |
})) | |
.use(include({ | |
deletePartials: true | |
})) | |
.use(layouts({ | |
engine: 'pug', | |
pretty: true, | |
directory: 'templates' | |
})) | |
.use(include({ | |
engine:'pug', | |
inPlace: true, | |
deletePartials: false | |
})) | |
.build(function(err, files){ | |
if (err) { | |
console.log('ERROR:',err) | |
return | |
} | |
console.log( 'Build Completed' ) | |
console.log( 'Files:', Object.keys( files ) ) | |
}) | |
/** | |
* Resulting content of public/home.html | |
<!-- Begin: home.pug--> | |
<div class="main"><h3 id="welcome-to-my-website-">Welcome to my website!</h3> | |
<h4 id="thanks-for-visiting-">Thanks for visiting!</h4> | |
</div> | |
<!-- End: home.pug--> | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment