-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheleventy.config.js
125 lines (113 loc) · 3.57 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
import { EleventyRenderPlugin } from '@11ty/eleventy'
import { feedPlugin } from '@11ty/eleventy-plugin-rss'
import pluginWebc from '@11ty/eleventy-plugin-webc'
import svgSprite from 'eleventy-plugin-svg-sprite'
import hljs from 'highlight.js'
import markdownIt from 'markdown-it'
import markdownItAnchor from 'markdown-it-anchor'
import markdownItAttrs from 'markdown-it-attrs'
import markdownItFootnote from 'markdown-it-footnote'
import markdownItTaskLists from 'markdown-it-task-lists'
import esbuild from './11ty/esbuild.js'
import prettierPlugin from './11ty/prettier.js'
/** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */
export default function (eleventyConfig) {
const input = 'www'
const output = 'dist/www'
const layouts = '_includes/layouts'
const components = [`${input}/_includes/components/**/*.webc`]
eleventyConfig.addPassthroughCopy(`${input}/assets`, { expand: true })
eleventyConfig.addPassthroughCopy(`${input}/**/*.{png,svg,jpg,jpeg,xsl,txt}`)
eleventyConfig.addPlugin(svgSprite, [
{
path: `${input}/assets/svg/common`,
svgSpriteShortcode: 'svgspriteCommon',
},
{
path: `${input}/assets/svg/photos`,
svgSpriteShortcode: 'svgspritePhotos',
},
])
eleventyConfig.addPlugin(EleventyRenderPlugin, { accessGlobalData: true })
eleventyConfig.addPlugin(pluginWebc, {
bundlePluginOptions: { toFileDirectory: 'assets/immutable/11ty/bundle/' },
components,
})
eleventyConfig.addPlugin(feedPlugin, {
type: 'rss',
outputPath: '/feed.xml',
collection: {
name: 'article',
limit: 0,
},
stylesheet: '/feed.xsl',
metadata: {
title: 'limulus.net',
subtitle: 'Every article on limulus.net.',
language: 'en',
base: 'https://limulus.net',
author: {
name: 'Eric McCarthy',
email: '[email protected]',
},
},
})
eleventyConfig.addPlugin(feedPlugin, {
type: 'atom',
outputPath: '/penumbra/feed.xml',
collection: {
name: 'penumbra',
limit: 0,
},
metadata: {
title: 'Penumbra Development Journal',
subtitle: 'Tracking the development of Penumbra, a web-centric ray tracer.',
language: 'en',
base: 'https://limulus.net/penumbra',
author: {
name: 'Eric McCarthy',
email: '[email protected]',
},
},
})
const md = markdownIt({
html: true,
highlight: (str, language) => {
if (language && hljs.getLanguage(language)) {
return (
'<pre><code class="hljs">' +
hljs.highlight(str, { language, ignoreIllegals: true }).value +
'</code></pre>'
)
}
return '' // use external default escaping
},
})
md.use(markdownItFootnote)
md.use(markdownItTaskLists)
md.use(markdownItAttrs)
md.use(markdownItAnchor)
eleventyConfig.setLibrary('md', md)
eleventyConfig.addPlugin(esbuild)
eleventyConfig.addPlugin(prettierPlugin)
eleventyConfig.addShortcode('getPhoto', function (id) {
const { photos } = this.$data
const photo = typeof photos[id] === 'string' ? photos[photos[id]] : photos[id]
if (!photo) {
throw new Error(`Photo with id "${id}" not found.`)
}
return photo
})
eleventyConfig.setServerOptions({
middleware: [
(_req, res, next) => {
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin')
res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp')
next()
},
],
port: process.env.PORT || 8080,
})
eleventyConfig.setServerPassthroughCopyBehavior('passthrough')
return { dir: { input, output, layouts } }
}