mirror of
https://github.com/seigler/dashdev-website
synced 2025-07-26 22:36:09 +00:00
initial commit
This commit is contained in:
commit
9169024ff0
60 changed files with 8596 additions and 0 deletions
25
lib/metalsmith-debug.js
Normal file
25
lib/metalsmith-debug.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
metalsmith-debug
|
||||
displays site metadata and page information in the console
|
||||
*/
|
||||
module.exports = function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
return function(files, metalsmith, done) {
|
||||
|
||||
console.log('\nMETADATA:');
|
||||
console.log(metalsmith.metadata());
|
||||
|
||||
for (var f in files) {
|
||||
|
||||
console.log('\nPAGE:');
|
||||
console.log(files[f]);
|
||||
|
||||
}
|
||||
|
||||
done();
|
||||
|
||||
};
|
||||
|
||||
};
|
94
lib/metalsmith-moremeta.js
Normal file
94
lib/metalsmith-moremeta.js
Normal file
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
metalsmith-meta
|
||||
adds further meta information to metalsmith files:
|
||||
root - the absolute or relative website root folder
|
||||
layout - sets from default from collection
|
||||
isPage - is an index page
|
||||
mainCollection - the primary collection name
|
||||
navmain - array of main navigation pages
|
||||
navsub - array of secondary navigation pages
|
||||
*/
|
||||
module.exports = function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
return function(files, metalsmith, done) {
|
||||
|
||||
var
|
||||
meta = metalsmith.metadata(),
|
||||
file, f, page, p, c, thisCol, layout;
|
||||
|
||||
for (f in files) {
|
||||
|
||||
file = files[f];
|
||||
|
||||
// calculate root
|
||||
file.root = file.root || meta.rootpath || (file.path ? '../'.repeat(file.path.split('/').length) : '');
|
||||
|
||||
// get first non-page collection
|
||||
file.mainCollection = null;
|
||||
file.isPage = false;
|
||||
c = 0;
|
||||
while (c < file.collection.length) {
|
||||
if (file.collection[c] == 'page') {
|
||||
file.isPage = true;
|
||||
}
|
||||
else {
|
||||
file.mainCollection = file.mainCollection || file.collection[c];
|
||||
}
|
||||
c++;
|
||||
}
|
||||
|
||||
// main navigation
|
||||
file.navmain = [];
|
||||
|
||||
for (p = 0; p < meta.collections.page.length; p++) {
|
||||
|
||||
page = meta.collections.page[p];
|
||||
if (!p || page.path != meta.collections.page[p-1].path) {
|
||||
file.navmain.push({
|
||||
title: page.title || 'Home',
|
||||
description: page.description || '',
|
||||
path: file.root + page.path + (page.path ? '/' : ''),
|
||||
dateFormat: page.dateFormat,
|
||||
active: page.path == file.path || page.collection.indexOf(file.mainCollection) >= 0
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (file.mainCollection) {
|
||||
|
||||
// get collection metadata
|
||||
thisCol = meta.collections[file.mainCollection];
|
||||
|
||||
// layout from page, collection, default
|
||||
layout = file.layout || (thisCol.metadata && thisCol.metadata.layout) || null;
|
||||
if (layout) file.layout = layout;
|
||||
|
||||
// secondary navigation
|
||||
file.navsub = [];
|
||||
for (p = 0; p < thisCol.length; p++) {
|
||||
|
||||
page = thisCol[p];
|
||||
if (page.collection.indexOf('page') < 0 && (!p || page.path != thisCol[p-1].path)) {
|
||||
file.navsub.push({
|
||||
title: page.title || 'Home',
|
||||
description: page.description || '',
|
||||
path: file.root + page.path + (page.path ? '/' : ''),
|
||||
dateFormat: page.dateFormat,
|
||||
active: page.path == file.path
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
done();
|
||||
|
||||
};
|
||||
|
||||
};
|
39
lib/metalsmith-setdate.js
Normal file
39
lib/metalsmith-setdate.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
metalsmith-setdate
|
||||
ensures every file has a date set
|
||||
adds dateFormat metadata with formatted creation date
|
||||
*/
|
||||
module.exports = function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
var month = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
||||
|
||||
return function(files, metalsmith, done) {
|
||||
|
||||
var file, f;
|
||||
|
||||
for (f in files) {
|
||||
|
||||
// get file object
|
||||
file = files[f];
|
||||
|
||||
// date from date, publish, file creation or now
|
||||
file.date =
|
||||
(Date.parse(file.date) && new Date(file.date)) ||
|
||||
(Date.parse(file.publish) && new Date(file.publish)) ||
|
||||
(file.stats && file.stats.ctime) || new Date();
|
||||
|
||||
// add a formatted date
|
||||
file.dateFormat =
|
||||
file.date.getUTCDate() + ' ' +
|
||||
month[file.date.getUTCMonth()] + ' ' +
|
||||
file.date.getUTCFullYear();
|
||||
|
||||
}
|
||||
|
||||
done();
|
||||
|
||||
};
|
||||
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue