diff options
Diffstat (limited to '.eleventy.js')
-rw-r--r-- | .eleventy.js | 85 |
1 files changed, 83 insertions, 2 deletions
diff --git a/.eleventy.js b/.eleventy.js index abbd9b8..96fd134 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -1,3 +1,84 @@ +const eleventysyntaxhighlight = require('@11ty/eleventy-plugin-syntaxhighlight') +const eleventyrss = require('@11ty/eleventy-plugin-rss') +const markdown = require('markdown-it') +const markdownattrs = require('markdown-it-attrs') +const { DateTime } = require('luxon') +const postcss = require('postcss') +const postcssenv = require('postcss-preset-env') +const babel = require("@babel/core"); +const env = require('./src/data/env') + module.exports = eleventyConfig => { - return require('./eleventy.config.js')(eleventyConfig) -} + eleventyConfig.addPlugin(eleventysyntaxhighlight) + eleventyConfig.addPlugin(eleventyrss) + + eleventyConfig.setLibrary('md', markdown({ + html: true, + linkify: true, + typographer: true + }).use(markdownattrs)) + + eleventyConfig.addFilter('datefmt', date => DateTime.fromJSDate(date, { zone: 'utc' }).toFormat("dd LLL yyyy")) + + eleventyConfig.addExtension("css", { + outputFileExtension: "css", + compile: async(content, filename) => + async data => { + const css = await postcss() + .use(postcssenv) + .process(content, { + from: filename, + map: data.env.isdevel + }) + + return css.css + } + }) + + eleventyConfig.addExtension("mjs", { + outputFileExtension: "js", + compile: (content, filename) => + async data => { + const js = await babel.transformAsync(content, { + presets: [ + ["@babel/preset-env", { + "targets": { + "esmodules": true, + }, + bugfixes: true + }] + ], + sourceMaps: data.env.isdevel ? "inline" : false, + sourceFileName: filename + }) + return js.code + } + }) + + + 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', + 'css', + 'mjs' + ] + } +}
\ No newline at end of file |