Last active
December 1, 2016 16:10
-
-
Save jhyland87/75a547711f4c37258f20f3f61a2748a1 to your computer and use it in GitHub Desktop.
hello-world.pug and head.pug template files
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
// Build with layouts() BEFORE include() | |
const fs = require( 'fs' ) | |
const path = require( 'path' ) | |
// Metalsmith stuff | |
const Metalsmith = require( 'metalsmith' ) | |
const markdown = require( 'metalsmith-markdownit' ) | |
const layouts = require( 'metalsmith-layouts' ) | |
const include = require( 'metalsmith-include') | |
const inplace = require( 'metalsmith-in-place' ) | |
const pug = require( 'metalsmith-pug' ) | |
const config = { | |
source: 'source', | |
buildPath: '_build' | |
} | |
Metalsmith(__dirname) | |
.source( config.source ) | |
.destination( config.buildPath ) | |
.clean(true) | |
.use(markdown({ | |
html: true, | |
xhtmlOut: true, | |
typographer: true, | |
linkify: true | |
})) | |
.use(layouts({ | |
engine: 'pug', | |
pretty: true, | |
directory: 'templates', | |
pattern: '**/*.html' | |
})) | |
.use(include()) | |
.build(function (err) { | |
if (err) { | |
console.log(err) | |
} | |
else { | |
console.log('Metalsmith complete!\n') | |
} | |
}) | |
/** | |
* _build/hello-world.html | |
<!-- Begin: hello-world.pug --><p>(<a href="http://hello-world.md">hello-world.md</a>) This file should show the rendered HTML data from head.pug, but it only shows the content from <a href="http://head.md">head.md</a></p> | |
<p>(File: hello-world.pug) This page includes the content from head.md, but not the rendered data from head.pug</p> | |
<!-- End: hello-world.pug --> | |
*/ |
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
//------------------------------- | |
//- File: templates/hello-world.pug | |
// Begin: hello-world.pug | |
//- I would expect this to show the rendered head.md file, including the head.pug data, but it only shows the "content" from head.md | |
!= head | |
!=contents | |
p (File: hello-world.pug) This page includes the content from head.md, but not the rendered data from head.pug | |
// End: hello-world.pug | |
//------------------------------- | |
//- File: templates/head.pug | |
// Begin: head.pug | |
!=contents | |
p (File: head.pug) This is the content that doesn't get rendered when this file is included | |
// End: head.pug |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment