-
Notifications
You must be signed in to change notification settings - Fork 0
/
eleventy.config.js
154 lines (126 loc) · 4.45 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import { DateTime } from 'luxon';
import esbuild from 'esbuild';
import markdownItAnchor from 'markdown-it-anchor';
import pluginRss from '@11ty/eleventy-plugin-rss';
import pluginBundle from '@11ty/eleventy-plugin-bundle';
import { EleventyHtmlBasePlugin } from '@11ty/eleventy';
import pluginSitemap from '@quasibit/eleventy-plugin-sitemap';
import pluginLit from '@lit-labs/eleventy-plugin-lit';
import pluginFavicons from 'eleventy-plugin-gen-favicons';
import pluginSEO from 'eleventy-plugin-seo';
import pluginGoogleFonts from 'eleventy-google-fonts';
import path from 'path';
import pluginImages from './eleventy.config.images.js';
import metadata from './_data/metadata.js';
export default async (eleventyConfig) => {
eleventyConfig.amendLibrary('md', (mdLib) => {
mdLib.use(markdownItAnchor, {
permalink: markdownItAnchor.permalink.headerLink(),
level: [1, 2, 3, 4],
slugify: eleventyConfig.getFilter('slugify')
});
});
eleventyConfig.addPassthroughCopy({
'./public/': '/'
});
eleventyConfig.addWatchTarget('content/**/*.{svg,webp,png,jpeg}');
// App plugins
eleventyConfig.addPlugin(pluginImages);
eleventyConfig.addPlugin(pluginLit, {
componentModules: [
'_components/my-hero.js',
'_components/my-nav.js',
'_components/my-preview.js',
'_components/my-section.js',
'_components/my-page.js',
'_components/my-product.js',
'_components/my-shares.js'
]
});
eleventyConfig.on('afterBuild', () => {
return esbuild.build({
entryPoints: ['node_modules/@lit-labs/ssr-client/lit-element-hydrate-support.js'],
bundle: true,
outfile: '_site/vendor/@lit-labs/ssr-client/lit-element-hydrate-support.js'
});
});
eleventyConfig.on('afterBuild', () => {
return esbuild.build({
entryPoints: ['_components/my-components.js'],
bundle: true,
outfile: '_site/bundle/my-components.js'
});
});
eleventyConfig.addWatchTarget('_components/**/*.js');
eleventyConfig.addPlugin(pluginSitemap, {
sitemap: {
hostname: metadata.url
}
});
eleventyConfig.addPlugin(pluginFavicons);
eleventyConfig.addPlugin(pluginSEO, {
title: metadata.title,
description: metadata.description,
url: metadata.url,
author: metadata.author.name,
twitter: 'grislyeye',
image: '/images/logo.svg',
options: {
imageWithBaseUrl: true
}
});
eleventyConfig.addPlugin(pluginGoogleFonts);
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addCollection('publishedPosts', (collectionApi) => {
return collectionApi
.getFilteredByTags('posts')
.filter((post) => !post.data.tags.includes('drafts'));
});
eleventyConfig.addPlugin(EleventyHtmlBasePlugin);
eleventyConfig.addPlugin(pluginBundle);
// Production dependencies
eleventyConfig.addPassthroughCopy(
{
'node_modules/@webcomponents/template-shadowroot': 'vendor/@webcomponents/template-shadowroot',
'node_modules/lit': 'vendor/lit',
'node_modules/@lit': 'vendor/@lit',
'node_modules/lit-element': 'vendor/lit-element',
'node_modules/lit-html': 'vendor/lit-html',
'node_modules/vellum-monster': 'vendor/vellum-monster',
'node_modules/@daviddarnes/share-button': 'vendor/@daviddarnes/share-button',
'node_modules/@micahilbery/share-on-mastodon': 'vendor/@micahilbery/share-on-mastodon'
}
);
eleventyConfig.addFilter('excludeTags', (posts, tags) => {
return posts.filter((post) => !post.data.tags.some((tag) => tags.includes(tag)));
});
eleventyConfig.addPassthroughCopy('content/**/*.{jpg,png}');
eleventyConfig.addFilter('readableDate', (dateObj, format, zone) => {
return DateTime.fromJSDate(dateObj, { zone: zone || 'utc' }).toFormat(format || 'dd LLLL yyyy');
});
eleventyConfig.addFilter('htmlDateString', (dateObj) => {
return DateTime.fromJSDate(dateObj, { zone: 'utc' }).toFormat('yyyy-LL-dd');
});
eleventyConfig.addNunjucksFilter('limit', (arr, limit) => arr.slice(0, limit));
eleventyConfig.addShortcode('backwardSupportPermalinkStem', (page) => {
return path.dirname(page.filePathStem);
});
eleventyConfig.addPassthroughCopy({ './robots.txt': './robots.txt' });
return {
templateFormats: [
'md',
'njk',
'html',
'liquid'
],
markdownTemplateEngine: 'njk',
htmlTemplateEngine: 'njk',
dir: {
input: 'content',
includes: '../_includes',
data: '../_data',
output: '_site'
},
pathPrefix: '/'
};
};