summaryrefslogtreecommitdiffstats
path: root/eleventy.config.js
blob: b2e2a5b3fbf8e00ceb77213dc6627788b3be11ce (plain) (blame)
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
module.exports = eleventyConfig => {
  eleventyConfig.addPlugin(require('@11ty/eleventy-plugin-syntaxhighlight'))
  eleventyConfig.addPlugin(require('@11ty/eleventy-plugin-rss'))

  eleventyConfig.setLibrary('md', require('markdown-it')({
    html: true,
    linkify: true,
    typographer: true
  }).use(require('markdown-it-attrs')))

  eleventyConfig.addTransform('htmlmin', (content, outputPath) => {
    if (outputPath && outputPath.endsWith('.html')) {
      const minified = require("html-minifier").minify(content, {
        useShortDoctype: true,
        removeComments: true,
        collapseWhitespace: true
      })
      return minified
    }

    return content
  })

  const { DateTime } = require('luxon')
  eleventyConfig.addFilter('datefmt', date => {
    return DateTime.fromJSDate(date, { zone: 'utc' }).toFormat("dd LLL yyyy");
  })

  eleventyConfig.addPassthroughCopy('static/')
  eleventyConfig.addPassthroughCopy('favicon.svg')
  eleventyConfig.addPassthroughCopy('favicon.ico')

  return {
    dir: {
      input: 'src',
      output: 'dist',
      includes: 'includes',
      data: 'data',
      layouts: 'layouts'
    },

    dataTemplateEngine: 'njk',
    markdownTemplateEngine: 'njk',
    htmlTemplateEngine: 'njk',
    templateFormats: [
      'html',
      'md',
      'njk',
      '11ty.js'
    ]
  }
}