-
Notifications
You must be signed in to change notification settings - Fork 197
/
.eleventy.js
92 lines (82 loc) · 2.85 KB
/
.eleventy.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
const yaml = require('js-yaml');
const navigationPlugin = require('@11ty/eleventy-navigation');
const path = require('path');
// Generate the shortened commit hash and create (overwrite) `build_info.json`
// file. This file will eventually be added to the footer of the page.
const writeBuildInfoToFile = () => {
const version = require('./package.json').version;
const commitHash = require('child_process')
.execSync('git rev-parse --short HEAD').toString().trim();
const commitDate = require('child_process')
.execSync('git show -s --format=%cd --date=short').toString().trim();
const currentYear = (new Date()).getFullYear();
const jsonData = JSON.stringify({
version: version,
revision: commitHash,
lastUpdated: commitDate,
copyrightYear: currentYear
});
const fs = require('fs');
fs.writeFileSync('src/_data/build_info.json', jsonData);
};
module.exports = function(eleventyConfig) {
writeBuildInfoToFile();
// See .eleventyignore for files to ignore.
eleventyConfig.setUseGitIgnore(false);
// To enable YAML files in `_data`.
eleventyConfig.addDataExtension('yaml', contents => yaml.load(contents));
// To handle relative paths and basic navigation via breadcrumbs.
eleventyConfig.addPlugin(navigationPlugin);
eleventyConfig.addFilter('relativePath', (fromPage, toUrl) => {
return path.relative(fromPage.url, toUrl);
});
if (process.env.ELEVENTY_ENV !== 'production') {
eleventyConfig.setBrowserSyncConfig({});
}
eleventyConfig.addWatchTarget('src/**/*.js');
eleventyConfig.addWatchTarget('src/styles/styles.css');
// Passthrough files via these glob patterns.
[
'src/library/**.js',
'src/archive/**/*.css',
'src/archive/**/*.html',
'src/archive/**/*.js',
'src/audio-worklet/**/*.html',
'src/audio-worklet/**/*.js',
'src/audio-worklet/**/*.mjs',
'src/demos/**/*.css',
'src/demos/**/*.gif',
'src/demos/**/*.html',
'src/demos/**/*.js',
'src/demos/**/*.mjs',
'src/demos/**/*.mp3',
'src/demos/**/*.png',
'src/demos/**/*.shader',
'src/demos/**/*.wav',
'src/demos/**/*.webmanifest',
'src/demos/**/*.zip',
'src/demos/wavetable-synth/wave-tables/*',
'src/experiments/**/*.html',
'src/experiments/**/*.js',
'src/sounds/drum-samples/**/*.wav',
'src/sounds/fx/**/*.wav',
'src/sounds/fx/**/*.mp3',
'src/sounds/hyper-reality/**/*.mp3',
'src/sounds/hyper-reality/**/*.wav',
'src/sounds/impulse-responses/**/*.wav',
'src/sounds/loops/**/*.wav',
'src/tests/**/*.css',
'src/tests/**/*.html',
'src/tests/**/*.js',
'src/tests/**/*.json',
'src/robots.txt',
'src/README.md',
'src/sitemap.xml',
'src/lib/**/*.js',
'src/lib/**/*.html',
].map(path => eleventyConfig.addPassthroughCopy(path));
// eleventyConfig.addPassthroughCopy('src/favicon');
return {
dir: {input: 'src'}
};
};