field-guide
Version:
a fully-functional, static site implementation of a design system documentation site
91 lines (73 loc) • 2 kB
JavaScript
/* eslint-disable prettier/prettier */
;
const path = require('path');
const resolve = require('resolve');
const walkSync = require('walk-sync');
const StaticSiteJson = require('broccoli-static-site-json');
const MergeTrees = require('broccoli-merge-trees');
const Funnel = require('broccoli-funnel');
const TableOfContents = require('./lib/table-of-contents');
module.exports = {
name: require('./package').name,
config(env, config) {
let fastboot = config.fastboot || {};
if(fastboot.hostWhitelist) {
fastboot.hostWhitelist.push(/localhost:\d+/);
} else {
fastboot.hostWhitelist = [/localhost:\d+/];
}
return {
fastboot,
}
},
treeForApp(tree) {
let backingClasses = new Funnel(
'docs',
{
destDir: 'components',
include: ['**/*.js']
}
);
return new MergeTrees([tree, backingClasses]);
},
included() {
this.import('vendor/ember/ember-template-compiler.js');
this.import('node_modules/prismjs/themes/prism.css');
this._super.included.apply(this, arguments);
},
treeForVendor(vendor) {
let templateCompilerTree = new Funnel(
path.dirname(resolve.sync('ember-source/package.json'), { basedir: this.project.root }),
{
srcDir: 'dist',
destDir: 'ember'
}
);
return new MergeTrees([
vendor,
templateCompilerTree,
].filter(Boolean));
},
treeForPublic: function() {
let docs = new StaticSiteJson('docs', {
contentFolder: 'docs',
collate: true,
contentTypes: ['content', 'html', 'toc'],
});
let toc = new TableOfContents(docs, {
subdir: 'docs',
});
return new MergeTrees([
docs,
toc,
]);
},
urlsForPrember() {
const content = walkSync('docs', {
globs: ['**/*.md'],
});
const staticUrls = ['/'];
const contentUrls = content.map(file => file.replace(/\.md$/, ''));
return [...staticUrls, ...contentUrls];
},
};