-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eleventy.js
157 lines (156 loc) · 5.97 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
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
148
149
150
151
152
153
154
155
156
157
const { DateTime } = require('luxon');
const { hydrogen_build } = require('@hydrogen-css/hydrogen/lib/build');
const eleventyNavigationPlugin = require('@11ty/eleventy-navigation');
const pluginRss = require('@11ty/eleventy-plugin-rss');
const UpgradeHelper = require('@11ty/eleventy-upgrade-help');
module.exports = function (eleventyConfig) {
eleventyConfig.setServerOptions({
// Default values are shown:
// Whether the live reload snippet is used
liveReload: true,
// Whether DOM diffing updates are applied where possible instead of page reloads
domDiff: false,
// The starting port number
// Will increment up to (configurable) 10 times if a port is already in use.
port: 8080,
// Additional files to watch that will trigger server updates
// Accepts an Array of file paths or globs (passed to `chokidar.watch`).
// Works great with a separate bundler writing files to your output folder.
// e.g. `watch: ["_site/**/*.css"]`
watch: [],
// Show local network IP addresses for device testing
showAllHosts: false,
// Use a local key/certificate to opt-in to local HTTP/2 with https
https: {
// key: "./localhost.key",
// cert: "./localhost.cert",
},
// Change the default file encoding for reading/serving files
encoding: 'utf-8',
// Show the dev server version number on the command line
showVersion: true,
});
// Add the Hydrogen configuration file as a watch target
eleventyConfig.addWatchTarget('./hydrogen.config.json');
// Add the Hydrogen library release directory as a watch target for easy reloading
eleventyConfig.addWatchTarget('../releases/**/*');
// Run Hydrogen after the eleventy build executes
eleventyConfig.on('eleventy.after', () => {
try {
hydrogen_build();
} catch (error) {
console.log(error);
}
});
// Add other plugins
eleventyConfig.addPlugin(eleventyNavigationPlugin);
eleventyConfig.addPlugin(pluginRss);
// Create a human readable date format
eleventyConfig.addFilter('readableDate', (dateObj) => {
return DateTime.fromJSDate(dateObj, { zone: 'utc' }).toFormat('dd LLL yyyy');
});
// date filter (localized)
eleventyConfig.addNunjucksFilter('date', function (date, format, locale) {
locale = locale ? locale : 'en';
moment.locale(locale);
return moment(date).format(format);
});
// Handle static assets
// Copy Static Files to /_Site
eleventyConfig.addPassthroughCopy({
'./src/static/css/app.css': './static/css/app.css',
'./src/static/css/duotone-sea.css': './static/css/duotone-sea.css',
'./src/static/css/synthwave.css': './static/css/synthwave.css',
'./src/static/css/laserwave.css': './static/css/laserwave.css',
'./node_modules/prismjs/themes/prism-funky.min.css': './static/css/prism-funky.min.css',
'./src/static/scripts/app.js': './static/js/app.js',
'./src/static/_redirects': './_redirects',
'./src/static/robots.txt': './robots.txt',
'./src/static/img': './static/img',
'./src/static/img/favicons': './',
});
// Build the English collections
// Full site
eleventyConfig.addCollection('en_site', function (collectionApi) {
return collectionApi.getFilteredByGlob('./src/en/**/*.11ty.js');
});
// Complete documentation
eleventyConfig.addCollection('en_docs', function (collectionApi) {
return collectionApi
.getFilteredByGlob('./src/en/docs/**/*.11ty.js')
.filter(function (item) {
return item.data.navigation.order;
})
.sort(function (a, b) {
if (!a.data.navigation.order);
else if (a.data.navigation.order > b.data.navigation.order) return 1;
else if (a.data.navigation.order < b.data.navigation.order) return -1;
else return 0;
});
});
// Installation
eleventyConfig.addCollection('en_installation', function (collectionApi) {
return collectionApi
.getFilteredByGlob('./src/en/docs/installation/*/*.11ty.js')
.filter(function (item) {
return item.data.navigation.order;
})
.sort(function (a, b) {
if (!a.data.navigation.order);
else if (a.data.navigation.order > b.data.navigation.order) return 1;
else if (a.data.navigation.order < b.data.navigation.order) return -1;
else return 0;
});
});
// Configuration
eleventyConfig.addCollection('en_configuration', function (collectionApi) {
return collectionApi
.getFilteredByGlob('./src/en/docs/configuration/*/*.11ty.js')
.filter(function (item) {
return item.data.navigation.order;
})
.sort(function (a, b) {
if (!a.data.navigation.order);
else if (a.data.navigation.order > b.data.navigation.order) return 1;
else if (a.data.navigation.order < b.data.navigation.order) return -1;
else return 0;
});
});
// Styling
eleventyConfig.addCollection('en_styling', function (collectionApi) {
return collectionApi
.getFilteredByGlob('./src/en/docs/styling/*/*.11ty.js')
.filter(function (item) {
return item.data.navigation.order;
})
.sort(function (a, b) {
if (!a.data.navigation.order);
else if (a.data.navigation.order > b.data.navigation.order) return 1;
else if (a.data.navigation.order < b.data.navigation.order) return -1;
else return 0;
});
});
// Properties
eleventyConfig.addCollection('en_properties', function (collectionApi) {
return collectionApi
.getFilteredByGlob('./src/en/docs/properties/*/*.11ty.js')
.filter(function (item) {
return item.data.navigation.order;
})
.sort(function (a, b) {
if (!a.data.navigation.order);
else if (a.data.navigation.order > b.data.navigation.order) return 1;
else if (a.data.navigation.order < b.data.navigation.order) return -1;
else return 0;
});
});
// Return the standard settings object
return {
dir: {
input: 'src',
includes: '_includes',
layouts: '_layouts',
},
templateFormats: ['11ty.js'],
};
};