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