Last active
June 2, 2016 00:22
-
-
Save lowmess/f8a8eed4c8e5cfd61d9c to your computer and use it in GitHub Desktop.
Default Metalsmith build
This file contains 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
node_modules | |
_build |
This file contains 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
var Metalsmith = require('metalsmith') | |
var sitemap = require('metalsmith-mapsite') | |
var feed = require('metalsmith-feed') | |
var defaultValues = require('metalsmith-default-values') | |
// HTML | |
var layouts = require('metalsmith-layouts') | |
var drafts = require('metalsmith-drafts') | |
var snippet = require('metalsmith-snippet') | |
var markdown = require('metalsmith-markdown') | |
var permalinks = require('metalsmith-permalinks') | |
var collections = require('metalsmith-collections') | |
var pagination = require('metalsmith-pagination') | |
var tags = require('metalsmith-tags') | |
// CSS | |
var sass = require('metalsmith-sass') | |
var prefix = require('metalsmith-autoprefixer') | |
// JS | |
var uglify = require('metalsmith-uglify') | |
// IMAGES | |
var imagemin = require('metalsmith-imagemin') | |
var siteBuild = Metalsmith(__dirname) | |
.source('source') | |
.destination('_build') | |
.metadata({ | |
site: { | |
title: 'My Metalsmith Site', | |
url: 'http://example.com', | |
description: 'A website, built with Metalsmith', | |
keywords: 'metalsmith, blog, static site generator' | |
} | |
}) | |
// CSS | |
.use(sass({ | |
includePaths: require('node-neat').includePaths, | |
outputStyle: 'compressed', | |
outputDir: 'css/' | |
})) | |
.use(prefix()) | |
// JS | |
.use(uglify({ | |
concat: 'js/main.js', | |
removeOriginal: true | |
})) | |
// IMAGES | |
.use(imagemin()) | |
// HTML | |
.use(drafts()) | |
.use(collections({ | |
blog: { | |
pattern: 'blog/**/*.md', | |
sortBy: 'date', | |
reverse: true | |
}, | |
pages: { | |
pattern: '*.md' | |
} | |
})) | |
// Set default values | |
.use(defaultValues([ | |
{ | |
pattern: 'blog/**/*.md', | |
defaults: { | |
layout: 'post.jade' | |
} | |
} | |
])) | |
.use(pagination({ | |
'collections.blog': { | |
perPage: 10, | |
layout: 'blog.jade', | |
first: 'blog/index.html', | |
noPageOne: true, | |
path: 'blog/page/:num/index.html', | |
pageMetadata: { | |
title: 'Blog' | |
} | |
} | |
})) | |
.use(markdown({ | |
gfm: true, | |
smartypants: true, | |
tables: true | |
})) | |
.use(snippet({ | |
maxLength: 140 | |
})) | |
.use(permalinks({ | |
pattern: ':collection/:title', | |
relative: false, | |
linksets: [{ | |
match: { collection: 'pages' }, | |
pattern: ':title' | |
}] | |
})) | |
.use(tags({ | |
handle: 'tags', | |
path:'tagged/:tag/index.html', | |
pathPage: "tagged/:tag/:num/index.html", | |
perPage: 10, | |
layout: 'tag.jade', | |
sortBy: 'date', | |
reverse: true | |
})) | |
.use(layouts({ | |
engine: 'jade', | |
moment: require('moment'), | |
directory: 'templates', | |
default: 'default.jade', | |
pattern: '**/*.html' | |
})) | |
.use(sitemap('http://example.com')) | |
.use(feed({collection: 'blog'})) | |
siteBuild.build(function (err) { | |
if (err) { | |
console.log(err) | |
} else { | |
console.log('Site build complete!') | |
} | |
}) |
This file contains 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
{ | |
"name": "my-metalsmith-site", | |
"version": "0.0.1", | |
"description": "A website, built with Metalsmith", | |
"engines": { | |
"node": "5.0.0" | |
}, | |
"main": "build.js", | |
"repository": { | |
"type": "git", | |
"url": "git+https://github.com/me/my-metalsmith-site.git" | |
}, | |
"keywords": [ | |
"metalsmith", | |
"blog" | |
], | |
"author": "Me", | |
"license": "MIT", | |
"bugs": { | |
"url": "https://github.com/me/my-metalsmith-site/issues" | |
}, | |
"homepage": "https://github.com/me/my-metalsmith-site#readme", | |
"devDependencies": { | |
"browser-sync": "^2.12.8", | |
"jade": "^1.11.0", | |
"metalsmith": "^2.1.0", | |
"metalsmith-autoprefixer": "^1.1.0", | |
"metalsmith-collections": "^0.7.0", | |
"metalsmith-default-values": "0.0.2", | |
"metalsmith-drafts": "0.0.1", | |
"metalsmith-feed": "^0.2.0", | |
"metalsmith-layouts": "^1.4.2", | |
"metalsmith-mapsite": "^1.0.4", | |
"metalsmith-markdown": "^0.2.1", | |
"metalsmith-pagination": "^1.4.0", | |
"metalsmith-permalinks": "^0.4.0", | |
"metalsmith-sass": "^1.3.0", | |
"metalsmith-snippet": "^2.0.0", | |
"metalsmith-tags": "^1.2.0", | |
"metalsmith-uglify": "^1.2.1", | |
"moment": "^2.11.1", | |
"node-neat": "^1.7.2", | |
"nodemon": "^1.9.2" | |
}, | |
"scripts": { | |
"start": "node build.js", | |
"browser_sync": "browser-sync start --server _build --no-ui --no-notify", | |
"develop": "npm run browser_sync & NODE_ENV=development nodemon --exec 'npm start && browser-sync reload'" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My default Metalsmith build.
.gitignore
,package.json
&build.js
to root of projectpackage.json
&build.js
to match your projectnpm start
now builds your project to the_build
directorynpm run develop
will watch files for changes and serve files tolocalhost:3000
Typical file tree structure: