forked from XYQuadrat/polyring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
59 lines (51 loc) · 1.75 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
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight')
const svgContents = require('eleventy-plugin-svg-contents')
const htmlMinifier = require('html-minifier')
function roundToTwo(x){
return Math.round((x + Number.EPSILON) * 100) / 100
}
module.exports = function (config) {
config.addPlugin(syntaxHighlight)
config.addPlugin(svgContents)
config.addLayoutAlias('base', 'base.njk')
config.addLayoutAlias('page', 'page.njk')
config.addFilter('mapNodes', function (nodes, radius, width, height) {
return nodes.map((node, index) => {
const angle = (index / (nodes.length / 2)) * Math.PI
const x = roundToTwo(radius * Math.cos(angle) + width / 2)
const y = roundToTwo(radius * Math.sin(angle) + height / 2)
return {
title: node.title,
url: node.url,
x,
y
}
})
})
config.addTransform('htmlmin', function (content, outputPath) {
if (outputPath.endsWith('.html')) {
return htmlMinifier.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true
})
}
return content
})
config.addPassthroughCopy('src/assets/images')
config.addPassthroughCopy('src/assets/themes')
config.addPassthroughCopy('src/data/members.json')
return {
dir: {
input: 'src',
output: 'dist',
includes: 'includes',
layouts: 'layouts',
data: 'data'
},
templateFormats: ['njk', 'md', '11ty.js'],
htmlTemplateEngine: 'njk',
markdownTemplateEngine: 'njk',
passthroughFileCopy: true
}
}