-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcubi.config.js
91 lines (87 loc) · 2.66 KB
/
cubi.config.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const path = require("path");
const { validateConfig } = require("cubi");
const { readArticles, readAbout, readResume } = require("./lib/readContent");
const { DIST_PATH } = require("./config");
function resolve(p) {
return path.resolve(__dirname, p);
}
module.exports = validateConfig({
rootPath: resolve("./src"),
name: "blog",
title: "blog",
htmlTemplate: path.resolve(__dirname, "./templates/index.html"),
entry: {
index: resolve("./src/view/Index"),
post: resolve("./src/view/Post"),
about: resolve("./src/view/About"),
resume: resolve("./src/view/Resume"),
archive: resolve("./src/view/Archive")
},
dllEntry: {
vendors: ["react", "react-dom", "lodash/debounce"],
__post: [
"highlight.js/styles/github.css",
"highlight.js/lib/highlight",
"highlight.js/lib/languages/javascript",
"highlight.js/lib/languages/typescript",
"highlight.js/lib/languages/css",
"highlight.js/lib/languages/xml"
]
},
outputPath: DIST_PATH,
devPort: 8687,
devServer: {
port: 8687
},
async exportPathMap() {
const articles = await readArticles();
const pages = articles.reduce(
(pages, file) =>
Object.assign({}, pages, {
[file.link]: {
page: "post",
title: file.title,
query: { content: file.result }
}
}),
{}
);
const aboutContent = await readAbout();
const resumeContent = await readResume();
return Object.assign({}, pages, {
index: {
page: "index",
title: "",
query: {
articles: articles.slice(0, 10).map(item => ({
link: item.link + ".html",
title: item.title
}))
}
},
archive: {
page: "archive",
title: "归档",
query: {
articles: articles.map(item => ({
link: item.link + ".html",
title: item.title
}))
}
},
about: {
page: "about",
title: "关于",
query: {
content: aboutContent
}
},
resume: {
page: "resume",
query: {
content: resumeContent
}
}
});
}
});