/
antwar.config.js
147 lines (133 loc) · 3.68 KB
/
antwar.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
const _ = require("lodash");
const path = require("path");
const EVENT_NAME = "Freezing Edge";
const CONFERENCE_ID = "freezing-edge-2020";
module.exports = {
apiUrl: "https://api.react-finland.fi/graphql",
conferenceId: CONFERENCE_ID,
template: {
file: path.resolve(__dirname, "templates/page.ejs"),
context: {
helmet: {},
},
},
renderPage: require("./utils/render-page"),
output: "build",
layout: () => require("./layouts/SiteBody").default,
paths: {
"404.html": page("404", {
description: "Page was not found",
title: "Page not found",
}),
"/": page(
"index",
{
title: EVENT_NAME,
description: `${EVENT_NAME} (01.06.2020, Helsinki) is a one day live coding workshop and meetup.`,
},
{
conferenceId: CONFERENCE_ID,
}
),
"for-attendees": page("for-attendees", {
title: "For Attendees",
description: `What should I know as a ${EVENT_NAME} attendee`,
}),
"for-speakers": page("for-speakers", {
title: "For Speakers",
description: `What should I know as a ${EVENT_NAME} speaker?`,
}),
"for-sponsors": page("for-sponsors", {
title: "For Sponsors",
description: `What should I know as a ${EVENT_NAME} sponsor?`,
}),
about: page("about", {
title: "Organizers",
description: `Who is organizing ${EVENT_NAME}?`,
}),
imprint: page("imprint", {
title: "Imprint",
description: `How to reach ${EVENT_NAME} organizers?`,
}),
"privacy-policy": page("privacy-policy", {
title: "Privacy Policy",
description: `What is the privacy policy of ${EVENT_NAME}?`,
}),
schedule: page(
"schedule",
{
title: "Schedule",
description: `What is the schedule of ${EVENT_NAME}?`,
},
{
conferenceId: CONFERENCE_ID,
}
),
speakers: page(
"speakers",
{
title: "Speakers",
speakers: `Who is going to speak at ${EVENT_NAME}?`,
},
{
conferenceId: CONFERENCE_ID,
}
),
workshops: page(
"workshops",
{
title: "Workshops",
description: `Which workshops will be held at ${EVENT_NAME}?`,
},
{
conferenceId: CONFERENCE_ID,
}
),
blog: {
content: () => require.context("./pages/blog", false, /^\.\/.*\.md$/),
index: () => {
const index = require("./layouts/BlogIndex").default;
index.title = "Blog";
index.description = "";
return index;
},
layout: () => require("./layouts/BlogPage").default,
transform: pages =>
generateAdjacent(_.sortBy(pages, "file.attributes.date")).reverse(),
url: ({ sectionName, fileName }) =>
`/${sectionName}/${cleanBlogPostName(fileName)}/`,
},
},
};
function cleanBlogPostName(resourcePath) {
const parts = resourcePath.split("/");
const beginning = parts.slice(0, -1);
const end = _.trimStart(parts.slice(-1)[0], "0123456789-_");
return beginning
.concat(end)
.join("/")
.toLowerCase()
.replace(/ /g, "-")
.replace(/_/g, "-");
}
function generateAdjacent(pages) {
return pages.map((page, i) => {
const ret = _.cloneDeep(page); // Avoid mutation
ret.previous = i > 0 && pages[i - 1];
ret.next = i < pages.length - 1 && pages[i + 1];
return ret;
});
}
function page(name, meta = {}, parameters) {
const ret = () => {
let pageComponent = require(`./pages/${name}`).default;
if (parameters) {
pageComponent = pageComponent(parameters);
}
pageComponent.description = meta.description;
pageComponent.title = meta.title;
return pageComponent;
};
ret.name = name;
return ret;
}