Created
September 18, 2018 16:21
-
-
Save autonome/20b809240d339537341a2a969369981c to your computer and use it in GitHub Desktop.
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
function build(callback) { | |
Metalsmith(__dirname) // __dirname defined by node.js: | |
// name of current working directory | |
.metadata({ // add any variable you want | |
// use them in layout-files | |
sitename: "foo", | |
siteurl: "https://foo.com/", | |
description: "Website!", | |
generatorname: "Metalsmith", | |
generatorurl: "https://metalsmith.io/" | |
}) | |
.source('ms-posts') // source directory | |
.destination('ms-site') // destination directory | |
.clean(true) // clean destination before | |
.use(collections({ // group all blog posts by internally | |
posts: 'ms-posts/*/*.md' // adding key 'collections':'posts' | |
})) // use `collections.posts` in layouts | |
.use(markdown()) // transpile all md into html | |
.use(drafts()) // Use the drafts plugin | |
.use(permalinks({ // change URLs to permalink URLs | |
pattern: ':date/:title', // generate URLs to YYYY/MM/DD/TITLE | |
relative: false // put css only in /css | |
})) | |
.use(feed({ // configure feeds | |
"site_url": "https://foo.com", | |
"metadata": { | |
"site": { | |
"title": "me", | |
"url": "https://foo.com", | |
"author": "me" | |
} | |
}, | |
"collection": "posts" | |
})) | |
//.use(layouts()) // wrap layouts around html | |
//.use(templates('handlebars')) // use handlebars templates | |
.build(function (err) { | |
var message = err ? err : 'Build complete'; | |
console.log(message); | |
callback(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment