generated from selfawarestudio/sane-eleventy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
93 lines (83 loc) · 2.49 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
const fs = require('fs')
const path = require('path')
const util = require('util')
const readFile = util.promisify(fs.readFile)
const cx = require('nanoclass')
// const blocksToHtml = require('@sanity/block-content-to-html')
// const client = require('./src/util/client')
// const imageUrlBuilder = require('@sanity/image-url')
// const builder = imageUrlBuilder(client)
// const linkResolver = require('./util/linkResolver')
module.exports = function(eleventyConfig) {
eleventyConfig.setUseGitIgnore(false)
eleventyConfig.addNunjucksAsyncShortcode('webpackAsset', async (name) => {
const manifestData = await readFile(
path.resolve(__dirname, 'src/templates/includes/_manifest.json'),
)
const manifest = JSON.parse(manifestData)
return manifest[name]
})
eleventyConfig.addShortcode(
'debug',
(value) =>
`<pre style="padding: 100px 0; font-size: 14px; font-family: monospace;">${JSON.stringify(
value,
null,
2,
)}</pre>`,
)
eleventyConfig.addShortcode('classNames', (...all) => cx(all))
// eleventyConfig.addFilter('href', linkResolver)
// eleventyConfig.addFilter('blocksToHtml', (blocks) => {
// try {
// const h = blocksToHtml.h
// const serializers = {
// marks: {
// externalLink: ({ children, mark }) =>
// h(
// 'a',
// {
// className: 'inline-link',
// href: mark.url,
// target: '_blank',
// rel: 'noopener noreferrer',
// },
// children,
// ),
// internalLink: ({ children, mark }) =>
// h(
// 'a',
// {
// className: 'inline-link',
// href: linkResolver({
// _type: 'internalLink',
// reference: mark.reference,
// }),
// },
// children,
// ),
// },
// }
// return blocksToHtml({ blocks, serializers })
// } catch (e) {
// return ''
// }
// })
// eleventyConfig.addShortcode('urlFor', (image, width) => {
// return builder
// .image(image)
// .width(width)
// .auto('format')
// .url()
// })
eleventyConfig.addPassthroughCopy({ 'src/assets': '/assets' })
return {
dir: {
input: 'src/templates',
data: '../data',
includes: 'includes',
layouts: 'layouts',
output: 'build',
},
}
}