forked from jonathantneal/mdcss-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
42 lines (34 loc) · 1019 Bytes
/
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
var ejs = require('ejs');
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 || 'https://i.imgur.com/3rqeZXi.png';
// set theme title
themeopts.title = themeopts.title || 'Style Guide';
// 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 compiled template
docs.template = ejs.compile(contents)(docs);
// resolve docs
resolve(docs);
}
});
});
};
};
module.exports.type = 'mdcss-theme';