mirror of
https://github.com/seigler/dashdev-website
synced 2025-07-26 22:36:09 +00:00
update
This commit is contained in:
parent
11885a3254
commit
c17e3b20c8
32 changed files with 540 additions and 199 deletions
222
build.js
222
build.js
|
@ -7,28 +7,28 @@ var pkg = require('./package.json');
|
|||
|
||||
// main directories
|
||||
dir = {
|
||||
base: __dirname + '/',
|
||||
lib: __dirname + '/lib/',
|
||||
source: './src/',
|
||||
dest: './build/'
|
||||
base: __dirname + '/',
|
||||
lib: __dirname + '/lib/',
|
||||
source: './src/',
|
||||
dest: './build/'
|
||||
};
|
||||
|
||||
siteMeta = {
|
||||
devBuild: devBuild,
|
||||
version: pkg.version,
|
||||
name: 'dashdevs-suite',
|
||||
desc: 'dashdevs-suite metalsmith website',
|
||||
author: 'dashdevs',
|
||||
contact: 'https://chat.dashdevs.org',
|
||||
domain: devBuild ? 'http://127.0.0.1' : 'https://dashdev-suite.github.io', // set domain
|
||||
rootpath: devBuild ? null : '/dashdev-website/build/' // set absolute path (null for relative)
|
||||
devBuild: devBuild,
|
||||
version: pkg.version,
|
||||
name: 'dashdevs-suite',
|
||||
desc: 'dashdevs-suite metalsmith website',
|
||||
author: 'dashdevs',
|
||||
contact: 'https://chat.dashdevs.org',
|
||||
domain: devBuild ? 'http://127.0.0.1' : 'https://dashdev-suite.github.io', // set domain
|
||||
rootpath: devBuild ? null : '/dashdev-website/build/' // set absolute path (null for relative)
|
||||
};
|
||||
|
||||
templateConfig = {
|
||||
engine: 'handlebars',
|
||||
directory: 'template/',
|
||||
partials: 'partials/',
|
||||
default: 'page.html'
|
||||
engine: 'handlebars',
|
||||
directory: 'template/',
|
||||
partials: 'partials/',
|
||||
default: 'page.html'
|
||||
};
|
||||
|
||||
// metalsmith
|
||||
|
@ -62,103 +62,115 @@ console.log((devBuild ? 'Development' : 'Production'), 'build, version', pkg.ver
|
|||
|
||||
// instantiate
|
||||
var metalsmith = Metalsmith(__dirname)
|
||||
.clean(true) // clean folder before a production build
|
||||
.source(dir.source + 'html/') // source folder (src/)
|
||||
.destination(dir.dest) // build folder (build/)
|
||||
.metadata(siteMeta) // add meta data to every page
|
||||
.use(publish()) // draft, private, future-dated
|
||||
.use(discoverPartials({ // needed for markdownPrecompiler
|
||||
directory: 'partials',
|
||||
pattern: /\.hbs$/ // original partials .html but exactly these parameters work
|
||||
}))
|
||||
// .use(json_to_files({
|
||||
// source_path: './box/'
|
||||
// }))
|
||||
.use(paths())
|
||||
.use(setdate()) // set date on every page if not set in front-matter
|
||||
.use(collections({ // determine page collection/taxonomy
|
||||
page: {
|
||||
pattern: '**/index.*',
|
||||
sortBy: 'priority',
|
||||
reverse: true,
|
||||
refer: false
|
||||
},
|
||||
start: {
|
||||
pattern: 'start/**/*',
|
||||
sortBy: 'priority',
|
||||
reverse: true,
|
||||
refer: true,
|
||||
metadata: {
|
||||
layout: './../src/layouts/article.hbs' // default is <root>/layouts
|
||||
}
|
||||
},
|
||||
article: {
|
||||
pattern: 'article/**/*',
|
||||
sortBy: 'date',
|
||||
reverse: true,
|
||||
refer: true,
|
||||
limit: 50,
|
||||
metadata: {
|
||||
layout: './../src/layouts/article.hbs'
|
||||
}
|
||||
}
|
||||
}))
|
||||
.use(markdownPrecompiler({ // convert {{> navmain}} in header.html
|
||||
engine: "handlebars",
|
||||
pattern: /\.md$/, // regex; no idea why .md works, check discoverPartials above
|
||||
partialsPath: './../partials',
|
||||
partials: ['navmain', 'navsub', 'footer', 'header', 'meta', 'pagelist']
|
||||
}))
|
||||
.use(markdown()) // convert markdown
|
||||
.use(permalinks({ // generate permalinks
|
||||
pattern: ':mainCollection/:title'
|
||||
}))
|
||||
.use(wordcount({ // word count
|
||||
raw: true
|
||||
}))
|
||||
.use(moremeta()) // determine root paths and navigation, TODO check remove
|
||||
// .use(inplace({
|
||||
// //engineOptions: {},
|
||||
// pattern: `partials.hbs/**`
|
||||
// }))
|
||||
.use(layouts({
|
||||
//engineOptions: {},
|
||||
pattern: `**/index.*`,
|
||||
default: './../src/layouts/page.hbs'
|
||||
}))
|
||||
// .use(layouts({
|
||||
// //engineOptions: {},
|
||||
// pattern: `article/**`,
|
||||
// default: 'article.hbs'
|
||||
// }))
|
||||
.clean(true) // clean folder before a production build
|
||||
.source(dir.source + 'html/') // source folder (src/)
|
||||
.destination(dir.dest) // build folder (build/)
|
||||
.metadata(siteMeta) // add meta data to every page
|
||||
.use(publish()) // draft, private, future-dated
|
||||
.use(discoverPartials({ // needed for markdownPrecompiler
|
||||
directory: 'partials',
|
||||
pattern: /\.hbs$/ // original partials .html but exactly these parameters work
|
||||
}))
|
||||
// .use(json_to_files({
|
||||
// source_path: './box/'
|
||||
// }))
|
||||
.use(paths())
|
||||
.use(setdate()) // set date on every page if not set in front-matter
|
||||
.use(collections({ // determine page collection/taxonomy
|
||||
page: {
|
||||
pattern: '**/index.*',
|
||||
sortBy: 'priority',
|
||||
reverse: true,
|
||||
refer: false
|
||||
},
|
||||
docs: {
|
||||
pattern: 'docs/**/*',
|
||||
sortBy: 'priority',
|
||||
reverse: true,
|
||||
refer: true,
|
||||
metadata: {
|
||||
layout: './../src/layouts/article.hbs' // default is <root>/layouts
|
||||
}
|
||||
},
|
||||
article: {
|
||||
pattern: 'article/**/*',
|
||||
sortBy: 'date',
|
||||
reverse: true,
|
||||
refer: true,
|
||||
limit: 50,
|
||||
metadata: {
|
||||
layout: './../src/layouts/article.hbs'
|
||||
}
|
||||
},
|
||||
tutorials: {
|
||||
pattern: 'tutorials/**/*',
|
||||
sortBy: 'priority',
|
||||
reverse: true,
|
||||
refer: true,
|
||||
limit: 50,
|
||||
},
|
||||
boxes: {
|
||||
pattern: 'boxes/**/*',
|
||||
sortBy: 'date',
|
||||
reverse: true,
|
||||
refer: true,
|
||||
limit: 50,
|
||||
}
|
||||
}))
|
||||
.use(markdownPrecompiler({ // convert {{> navmain}} in header.html
|
||||
engine: "handlebars",
|
||||
pattern: /\.md$/, // regex; no idea why .md works, check discoverPartials above
|
||||
partialsPath: './../partials',
|
||||
partials: ['navmain', 'navsub', 'footer', 'header', 'meta', 'pagelist']
|
||||
}))
|
||||
.use(markdown()) // convert markdown
|
||||
.use(permalinks({ // generate permalinks
|
||||
pattern: ':mainCollection/:title'
|
||||
}))
|
||||
.use(wordcount({ // word count
|
||||
raw: true
|
||||
}))
|
||||
.use(moremeta()) // determine root paths and navigation, TODO check remove
|
||||
// .use(inplace({
|
||||
// //engineOptions: {},
|
||||
// pattern: `partials.hbs/**`
|
||||
// }))
|
||||
.use(layouts({
|
||||
//engineOptions: {},
|
||||
pattern: `**/index.*`,
|
||||
default: './../src/layouts/page.hbs'
|
||||
}))
|
||||
// .use(layouts({
|
||||
// //engineOptions: {},
|
||||
// pattern: `article/**`,
|
||||
// default: 'article.hbs'
|
||||
// }))
|
||||
|
||||
if (htmlmin) metalsmith.use(htmlmin()); // minify production HTML
|
||||
|
||||
if (debug) metalsmith.use(debug()); // output page debugging information
|
||||
|
||||
if (browsersync) metalsmith.use(browsersync({ // start test server
|
||||
server: dir.dest,
|
||||
files: [dir.source + '**/*']
|
||||
server: dir.dest,
|
||||
files: [dir.source + '**/*']
|
||||
}));
|
||||
|
||||
metalsmith
|
||||
.use(sitemap({ // generate sitemap.xml
|
||||
hostname: siteMeta.domain + (siteMeta.rootpath || ''),
|
||||
omitIndex: true // replace any paths ending in index.html with ''. Useful when you're using metalsmith-permalinks.
|
||||
}))
|
||||
.use(rssfeed({ // generate RSS feed for articles
|
||||
collection: 'article',
|
||||
site_url: siteMeta.domain + (siteMeta.rootpath || ''),
|
||||
title: siteMeta.name,
|
||||
description: siteMeta.desc
|
||||
}))
|
||||
.use(assets({ // copy assets: CSS, images etc.
|
||||
source: dir.source + 'assets/',
|
||||
destination: './'
|
||||
}))
|
||||
.use(sitemap({ // generate sitemap.xml
|
||||
hostname: siteMeta.domain + (siteMeta.rootpath || ''),
|
||||
omitIndex: true // replace any paths ending in index.html with ''. Useful when you're using metalsmith-permalinks.
|
||||
}))
|
||||
.use(rssfeed({ // generate RSS feed for articles
|
||||
collection: 'article',
|
||||
site_url: siteMeta.domain + (siteMeta.rootpath || ''),
|
||||
title: siteMeta.name,
|
||||
description: siteMeta.desc
|
||||
}))
|
||||
.use(assets({ // copy assets: CSS, images etc.
|
||||
source: dir.source + 'assets/',
|
||||
destination: './'
|
||||
}))
|
||||
|
||||
.build(function (err) {
|
||||
.build(function(err) {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue