-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eleventy.config.js
136 lines (120 loc) Β· 3.46 KB
/
eleventy.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
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
import { collections, filters, shortcodes } from './config/11ty/index.js';
import pluginExternalLinks from '@aloskutov/eleventy-plugin-external-links';
import pluginRSS from '@ryanccn/eleventy-plugin-rss';
import pluginTOC from '@uncenter/eleventy-plugin-toc';
import pluginAutoCacheBuster from 'eleventy-auto-cache-buster';
import pluginIcons from 'eleventy-plugin-icons';
import pluginValidate from 'eleventy-plugin-validate';
import { VentoPlugin } from 'eleventy-plugin-vento';
import markdownLibrary from './config/markdown/core.js';
import {
processCss,
processSass,
processTailwindCss,
} from './config/transforms/css.js';
import { minifyHtml } from './config/transforms/html.js';
import { z } from 'zod';
import 'dotenv/config';
const isDevelopment = process.env.NODE_ENV !== 'production';
import colors from 'picocolors';
import site from './site.config.js';
import eleventy from '11ty.ts';
export default eleventy(function (eleventyConfig) {
eleventyConfig.addGlobalData('site', site);
eleventyConfig.addPlugin(shortcodes);
eleventyConfig.addPlugin(collections);
eleventyConfig.addPlugin(filters);
/* Plugins */
eleventyConfig.addPlugin(pluginTOC, {
ul: true,
wrapper: function (toc) {
return toc;
},
});
eleventyConfig.addPlugin(pluginExternalLinks, {
url: site.author.url,
rel: ['noreferrer'],
overwrite: false,
enableTarget: false,
});
eleventyConfig.addPlugin(pluginRSS);
eleventyConfig.addPlugin(pluginAutoCacheBuster);
eleventyConfig.addPlugin(pluginIcons, {
mode: 'inline',
sources: [
{ name: 'si', path: 'node_modules/simple-icons/icons' },
{ name: 'lucide', path: 'node_modules/lucide-static/icons' },
],
icon: {
errorNotFound: false,
class: function (name, source) {
return `icon icon-${name} icon-${source}`;
},
},
});
eleventyConfig.addPlugin(pluginValidate, {
validator: 'zod',
schemas: [
{
collections: ['posts'],
schema: z
.object({
tags: z.array(z.string()),
title: z.string(),
description: z.string(),
date: z.date(),
edited: z.date().optional(),
comments: z.boolean(),
})
.strict(),
},
],
});
eleventyConfig.addPlugin(VentoPlugin);
/* Passthrough Copy */
eleventyConfig.addPassthroughCopy({ 'public/': '.' });
/* Other Config */
eleventyConfig.addTransform('html', function (content) {
if (this.page.outputPath && this.page.outputPath.endsWith('.html')) {
return minifyHtml(content);
}
return content;
});
eleventyConfig.setLibrary('md', markdownLibrary);
eleventyConfig.setQuietMode(isDevelopment);
eleventyConfig.setServerOptions({
port: process.env.PORT || 8080,
portReassignmentRetryCount: 0,
});
eleventyConfig.addTemplateFormats('scss');
eleventyConfig.addExtension('scss', {
outputFileExtension: 'css',
compile: async function (inputContent) {
return async () => {
return processCss(
await processTailwindCss(await processSass(inputContent)),
);
};
},
});
// Give me the localhost URL after every rebuild so I don't have to scroll up to find it.
let notFirstRun = false;
eleventyConfig.on('eleventy.after', async ({ runMode }) => {
if (runMode === 'serve') {
if (notFirstRun)
console.log(colors.blue('\n[11ty] Server at http://localhost:8080/\n'));
notFirstRun = true;
}
});
return {
dir: {
input: 'src',
output: 'dist',
includes: 'components',
layouts: 'layouts',
data: '_data',
},
templateFormats: ['md', 'vto', '11ty.js'],
markdownTemplateEngine: 'vto',
};
});