-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.eleventy.js
211 lines (183 loc) · 4.92 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
const siteName = "ZeroPoint";
/**
* Wait! Before you edit this file!
* This Eleventy-based project abstracts the traditional `.eleventy.js` file to help keep things clean and tidy.
* Consider editing the following files instead:
* - `src/config/collections.js`
* - `src/config/passthroughs.js`
* - `src/config/plugins.js`
* - `src/config/shortcodes.js`
* - `src/config/watchtargets.js`
* - `src/config/templateLanguages.js`
* - `src/config/filters.js`
* - `src/config/transforms.js`
*/
/**
* Passthroughs and file copies are defined as named exports in /src/config/passthroughs.js
*/
import passthroughs from './src/config/passthroughs.js';
/**
* Collections are defined as named exports in /src/config/collections.js
*/
import collections from './src/config/collections.js';
/**
* Watch targets are defined as named exports in /src/config/watchtargets.js
*/
import watchtargets from './src/config/watchtargets.js';
/**
* Plugins are defined as named exports in /src/config/plugins.js
*/
import plugins from './src/config/plugins.js';
/**
* Shortcodes are defined as named exports in /src/config/shortcodes.js
*/
import shortcodes from './src/config/shortcodes.js';
/**
* Custom template languages are defined as named exports in /src/config/templateLanguages.js
*/
import templatelanguages from './src/config/templateLanguages.js';
/**
* Filters are defined as named exports in /src/config/filters.js
*/
import filters from './src/config/filters.js';
/**
* Import the bundler configuration from /src/config/build.js
*/
import build from './src/config/build.js';
/**
* Import transforms from /src/config/transforms.js
*/
import transforms from './src/config/transforms.js';
/**
* Any additional requirements can be added here
*/
import chalk from 'chalk';
/**
* Eleventy configuration
* https://www.11ty.dev/docs/config/
*/
export default function(eleventyConfig) {
// An array of the tasks to be run, in order, with an icon and a pretty name for each
// Put the tasks in the order you want them to run, and set echo to false if you don't want to log the task to the console
let tasks = [
{
icon: "📚",
name: "Collections",
config: collections,
echo: true,
},
{
icon: "🔌",
name: "Plugins",
config: plugins,
echo: true,
},
{
icon: "⏩",
name: "Shortcodes",
config: shortcodes,
echo: true,
},
{
icon: "🎛️ ",
name: "Filters",
config: filters,
echo: true,
},
{
icon: "🚗",
name: "Transforms",
config: transforms,
echo: true,
},
{
icon: "📂",
name: "Passthroughs",
config: passthroughs,
echo: false,
},
{
icon: "📜",
name: "Template Languages",
config: templatelanguages,
echo: false,
},
{
icon: "👀",
name: "Watch Targets",
config: watchtargets,
echo: false,
}
];
/**
* Start pretty console output
*/
console.group("\n", " 🪐", chalk.magenta(siteName));
console.log(chalk.white(" │"));
for (let task of tasks) {
let tree = tasks.indexOf(task) === tasks.length - 1;
// If the next tasks's echo is false, don't log the tree
tree = (tasks[tasks.indexOf(task) + 1] && !tasks[tasks.indexOf(task) + 1].echo);
if(task.echo) {
console.group(
chalk.white((tree) ? " └── " : " ├── ") +
chalk.yellow(task.icon) +
chalk.yellow(" " + task.name) +
chalk.gray(" (/src/config/" + task.name.toLowerCase().replace(/\s/g, '') + ".js)")
);
}
Object.keys(task.config).forEach((taskName, index) => {
let len = Object.keys(task.config).length - 1;
let pre = (index === len ? "└── " : "├── ");
let branch = tasks.indexOf(task) === tasks.length - 1;
branch = (tasks[tasks.indexOf(task) + 1] && !tasks[tasks.indexOf(task) + 1].echo);
if(task.echo) {
console.log(
chalk.white((branch) ? " " : "│ ") + pre +
chalk.green(taskName)
);
}
// Run the task
task.config[taskName](eleventyConfig);
});
if(task.echo) {
if(!tree) {
console.log(chalk.white("│"));
}
console.groupEnd();
}
}
console.log("\n");
console.groupEnd();
/**
* End pretty console output
*/
/**
* Add build configuration from /src/config/build.js
*/
build(eleventyConfig);
/**
* Configure dev server
* https://www.11ty.dev/docs/watch-serve/#eleventy-dev-server
*/
eleventyConfig.setServerOptions({
showAllHosts: true,
});
/**
* Enable quiet mode
*/
eleventyConfig.setQuietMode(true);
/**
* Return the config to Eleventy
*/
return {
dir: {
input: "src",
output: "public",
includes: 'assets/views',
layouts: 'assets/views/layouts',
data: 'data',
},
templateFormats: ['njk', 'md', '11ty.js'],
};
}