-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.js
63 lines (58 loc) · 1.95 KB
/
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
import path from 'path';
import url from 'url';
const env = process.env.NODE_ENV || 'development';
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
/** @typedef {import('@eprev/wsngn').RewriteFunction} RewriteFunction */
/** @typedef {typeof config['site']} ConfigSite */
const config = {
src: path.join(__dirname, 'source'),
dest: path.join(__dirname, 'static'),
env,
site: {
title: 'Anton Eprev',
description:
'My name’s Anton Eprev and I’m a software engineer working ' +
'as front-end developer at Booking.com in Amsterdam. ' +
'Tinker with electronics and 3D printers in spare time.',
url: env === 'production' ? 'https://eprev.org' : 'http://localhost:3000',
twitter: 'eprev',
editUrl: 'https://github.com/eprev/eprev.org/blob/master/source',
},
serverUrl: 'http://localhost:3000',
exclude: ['/gif/src', '/gif/Makefile'],
/** @type {RewriteFunction[]} */
rewrites: [
[
/^\/posts\/(\d{4})-(\d{2})-(\d{2})-([^/.]+)(?:\/(.+)|\.md)?$/,
(doc, [pathname, yyyy, mm, dd, slug, filename]) => {
if (filename === `${slug}.md` || filename === undefined) {
doc.type = 'post';
doc.date = new Date(
Date.UTC(Number(yyyy), Number(mm) - 1, Number(dd)),
);
filename = ''; // eq. index.html
if (!doc.layout) {
doc.layout = 'post';
}
}
doc.pathname = `/${yyyy}/${mm}/${dd}/${slug}/${filename}`;
},
],
[
/^\/posts\/drafts\/([^/.]+)(?:\/(.+)|\.md)?$/,
(doc, [pathname, slug, filename]) => {
if (filename === `${slug}.md` || filename === undefined) {
doc.type = 'post';
doc.date = new Date();
doc.draft = true;
filename = ''; // eq. index.html
if (!doc.layout) {
doc.layout = 'post';
}
}
doc.pathname = `/drafts/${slug}/${filename}`;
},
],
],
};
export default config;