-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
177 lines (152 loc) · 5.16 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
const EleventyPluginTagCloud = require('eleventy-plugin-tag-cloud');
const EleventyPoison = require('eleventy-plugin-poison');
// const schema = require("@quasibit/eleventy-plugin-schema");
require('dotenv').config();
const EleventyPluginPlausible = require('eleventy-plugin-plausible');
const markdownIt = require('markdown-it')
const markdownItAnchor = require('markdown-it-anchor')
const EleventyWebMentions = require('eleventy-plugin-webmentions');
const EleventyRocksReadTime = require('@11tyrocks/eleventy-plugin-emoji-readtime')
const EleventyInclusiveLanguage = require('@11ty/eleventy-plugin-inclusive-language')
const { EleventyEdgePlugin } = require('@11ty/eleventy')
const EleventyPluginNavigation = require('@11ty/eleventy-navigation')
const EleventyPluginRss = require('@11ty/eleventy-plugin-rss')
const EleventyPluginSyntaxhighlight = require('@11ty/eleventy-plugin-syntaxhighlight')
const EleventyVitePlugin = require('@11ty/eleventy-plugin-vite')
const rollupPluginCritical = require('rollup-plugin-critical').default
const filters = require('./utils/filters.js')
const transforms = require('./utils/transforms.js')
const shortcodes = require('./utils/shortcodes.js')
const { resolve } = require('path')
module.exports = function (eleventyConfig) {
eleventyConfig.setServerPassthroughCopyBehavior('copy');
eleventyConfig.addPassthroughCopy("public");
// Plugins
eleventyConfig.addPlugin(EleventyPluginTagCloud);
eleventyConfig.addPlugin(EleventyWebMentions, {
domain: 'ginger.wtf',
token: process.env.INDIE_WEB_TOKEN
});
eleventyConfig.addPlugin(EleventyRocksReadTime);
eleventyConfig.addPlugin(EleventyPluginPlausible, {
domain: 'ginger.wtf',
proxyPath: '/js/script',
exclude: [ '/style/', '/test' ],
});
eleventyConfig.addPlugin(EleventyPoison);
eleventyConfig.addPlugin(EleventyPluginNavigation)
eleventyConfig.addPlugin(EleventyPluginRss)
eleventyConfig.addPlugin(EleventyInclusiveLanguage)
eleventyConfig.addPlugin(EleventyPluginSyntaxhighlight)
eleventyConfig.addPlugin(EleventyEdgePlugin)
eleventyConfig.addPlugin(EleventyVitePlugin, {
tempFolderName: '.11ty-vite', // Default name of the temp folder
// Vite options (equal to vite.config.js inside project root)
viteOptions: {
publicDir: 'public',
clearScreen: false,
server: {
mode: 'development',
middlewareMode: true,
},
appType: 'custom',
assetsInclude: ['**/*.xml', '**/*.txt'],
build: {
mode: 'production',
sourcemap: 'true',
manifest: false,
modulePreload: false,
// This puts CSS and JS in subfolders – remove if you want all of it to be in /assets instead
rollupOptions: {
output: {
assetFileNames: 'assets/css/main.[hash].css',
chunkFileNames: 'assets/js/[name].[hash].js',
entryFileNames: 'assets/js/[name].[hash].js'
},
plugins: [rollupPluginCritical({
criticalUrl: './_site/',
criticalBase: './_site/',
criticalPages: [
{ uri: 'index.html', template: 'index' },
{ uri: 'posts/index.html', template: 'posts/index' },
{ uri: '404.html', template: '404' },
],
criticalConfig: {
inline: true,
dimensions: [
{
height: 900,
width: 375,
},
{
height: 720,
width: 1280,
},
{
height: 1080,
width: 1920,
}
],
penthouse: {
forceInclude: [
'.fonts-loaded-1 body',
'.fonts-loaded-2 body',
],
}
}
})
]
}
}
}
})
// Filters
Object.keys(filters).forEach((filterName) => {
eleventyConfig.addFilter(filterName, filters[filterName])
})
// Transforms
Object.keys(transforms).forEach((transformName) => {
eleventyConfig.addTransform(transformName, transforms[transformName])
})
// Shortcodes
Object.keys(shortcodes).forEach((shortcodeName) => {
eleventyConfig.addShortcode(shortcodeName, shortcodes[shortcodeName])
})
eleventyConfig.addShortcode('serifName', () => `<span class="serif serif-name"><span class="rotate">G</span>inger</span>`)
eleventyConfig.addShortcode('year', () => `${new Date().getFullYear()}`)
// Customize Markdown library and settings:
let markdownLibrary = markdownIt({
html: true,
breaks: true,
linkify: true
}).use(markdownItAnchor, {
permalink: markdownItAnchor.permalink.linkInsideHeader({
placement: 'before',
class: 'direct-link',
symbol: `<span aria-hidden="true">#</span>
<span class="visually-hidden">Jump to heading</span>`,
level: [1, 2, 3]
}),
slugify: eleventyConfig.getFilter('slug')
})
eleventyConfig.setLibrary('md', markdownLibrary)
// Layouts
eleventyConfig.addLayoutAlias('base', 'base.njk')
eleventyConfig.addLayoutAlias('post', 'post.njk')
// Copy/pass-through files
eleventyConfig.addPassthroughCopy('src/assets/css')
eleventyConfig.addPassthroughCopy('src/assets/js')
return {
templateFormats: ['md', 'njk', 'html', 'liquid'],
htmlTemplateEngine: 'njk',
passthroughFileCopy: true,
dir: {
input: 'src',
// better not use "public" as the name of the output folder (see above...)
output: '_site',
includes: '_includes',
layouts: 'layouts',
data: '_data'
}
}
}