This repository has been archived by the owner on May 26, 2021. It is now read-only.
forked from jonathantneal/mdcss-theme-github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
69 lines (55 loc) · 1.8 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
var ejs = require('ejs');
var ext = require('object-assign');
var fs = require('fs');
var path = require('path');
module.exports = function (themeopts) {
// set theme options object
themeopts = Object(themeopts);
// set theme logo
themeopts.logo = themeopts.logo || 'mdcss-logo.png';
// set theme title
themeopts.title = themeopts.title || 'Style Guide';
// set theme css
themeopts.css = themeopts.css || ['primer.css', 'style.css', 'octicons/octicons.css'];
// set theme css
themeopts.js = themeopts.js || [];
// set theme masthead color
themeopts.color = themeopts.color || ['#4078c0'];
// set navigation links
themeopts.nav = themeopts.nav || [];
// set example conf
themeopts.examples = ext({
base: '',
target: '_self',
css: ['style.css'],
js: [],
bodyjs: [],
htmlcss: 'background:none;border:0;clip:auto;display:block;height:auto;margin:0;padding:0;position:static;width:auto',
bodycss: 'background:none;border:0;clip:auto;display:block;height:auto;margin:0;padding:16px;position:static;width:auto'
}, themeopts.examples);
// return theme
return function (docs) {
// set assets directory and template
docs.assets = path.join(__dirname, 'assets');
docs.template = path.join(__dirname, 'template.ejs');
// set theme options
docs.themeopts = themeopts;
// return promise
return new Promise(function (resolve, reject) {
// read template
fs.readFile(docs.template, 'utf8', function (error, contents) {
// throw if template could not be read
if (error) reject(error);
else {
// set examples options
docs.opts = ext({}, docs.opts, docs.themeopts);
// set compiled template
docs.template = ejs.compile(contents)(docs);
// resolve docs
resolve(docs);
}
});
});
};
};
module.exports.type = 'mdcss-theme';