-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmetalsmith.js
More file actions
55 lines (53 loc) · 1.51 KB
/
Copy pathmetalsmith.js
File metadata and controls
55 lines (53 loc) · 1.51 KB
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
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import Metalsmith from 'metalsmith';
import layouts from '@metalsmith/layouts';
import inPlace from '@metalsmith/in-place';
import cotd from './cotd.json' with { type: 'json' };
import clueOfTheDay from './lib/clue-of-the-day.js';
import versionControl from './lib/version-control.js';
import setUpTemplates from './lib/templates.js';
import hotClues from './lib/hot-clues.js';
Metalsmith(dirname(fileURLToPath(import.meta.url)))
.clean(true)
.source('./src')
.destination('./build')
.metadata({
builtAt: new Date().toISOString(),
})
.use(
setUpTemplates({
header: '_header.html',
footer: '_footer.html',
cotd: '_clue_card.html',
solve: '_solve.html',
}),
)
.use(hotClues)
.use(versionControl)
.use(clueOfTheDay(cotd))
.use(function original_filename(files) {
Object.keys(files).forEach((file) => {
files[file].original_filename = `src/${file}`;
});
})
.use(
inPlace({
transform: 'handlebars',
pattern: '*.(html|xml)',
extname: '*.(html|xml)',
}),
)
.use(
layouts({
transform: 'handlebars',
pattern: '*.html',
directory: 'layouts',
default: 'base.html',
extName: false,
}),
)
.env('DEBUG', '@metalsmith/layouts*')
.build((err) => {
if (err) throw err;
});