1 |
|
2 |
|
3 |
|
4 | const fs = require('fs');
|
5 | const sh = require('child_process').execSync;
|
6 |
|
7 |
|
8 | module.exports = (config) => {
|
9 |
|
10 | const dist = config.theme + '/tmp';
|
11 | const nav = config.nav;
|
12 |
|
13 | let out = '';
|
14 |
|
15 | nav.forEach(item => {
|
16 | let str = '{';
|
17 | if (/^https?.*/.test(item.uri)) {
|
18 | str += `http: "${item.uri}",\n`;
|
19 | } else {
|
20 | str += `md: require("${item.uri}"),\n`;
|
21 | }
|
22 | str += `label: "${item.label}",\n`;
|
23 | str += `uri: "${item.uri}"\n`;
|
24 |
|
25 | str += '}\n';
|
26 |
|
27 | out += str + ',';
|
28 | });
|
29 |
|
30 | out = `module.exports = [${out}];`;
|
31 | fs.writeFileSync(dist + `/__nav__.js`, out);
|
32 |
|
33 | } |
\ | No newline at end of file |