2023-01-09 20:10:02 +01:00
|
|
|
'use strict';
|
2023-01-06 23:37:45 +01:00
|
|
|
|
2023-02-02 21:52:26 +01:00
|
|
|
const { EleventyRenderPlugin } = require('@11ty/eleventy');
|
2023-01-26 21:56:20 +01:00
|
|
|
const formatDistanceToNow = require('date-fns/formatDistanceToNow');
|
2023-01-24 23:51:07 +01:00
|
|
|
const yaml = require('js-yaml');
|
|
|
|
const markdown = require('markdown-it');
|
2023-01-29 20:17:04 +01:00
|
|
|
const markdownDefList = require('markdown-it-deflist');
|
2023-01-24 23:51:07 +01:00
|
|
|
const typogrify = require('typogr');
|
|
|
|
|
2023-01-06 22:40:29 +01:00
|
|
|
/** @param {import('@11ty/eleventy').UserConfig} eleventyConfig */
|
2023-01-06 23:37:45 +01:00
|
|
|
module.exports = (eleventyConfig) => {
|
2023-01-09 20:10:02 +01:00
|
|
|
eleventyConfig.addPassthroughCopy('source/assets/dist');
|
|
|
|
eleventyConfig.addPassthroughCopy('source/assets/img');
|
|
|
|
eleventyConfig.addPassthroughCopy('source/favicon.ico');
|
2023-01-06 22:40:29 +01:00
|
|
|
|
2023-01-10 23:05:39 +01:00
|
|
|
eleventyConfig.setLiquidOptions({
|
|
|
|
jsTruthy: true,
|
|
|
|
});
|
2023-01-11 18:30:24 +01:00
|
|
|
eleventyConfig.setUseGitIgnore(false);
|
2023-02-02 22:14:26 +01:00
|
|
|
eleventyConfig.watchIgnores.add('source/_data/versionCache.json');
|
2023-01-10 23:05:39 +01:00
|
|
|
|
2023-01-24 23:51:07 +01:00
|
|
|
const mdown = markdown({
|
|
|
|
html: true,
|
|
|
|
typographer: true,
|
2023-01-29 21:04:56 +01:00
|
|
|
}).use(markdownDefList);
|
2023-01-24 23:51:07 +01:00
|
|
|
|
|
|
|
eleventyConfig.setLibrary('md', mdown);
|
2023-02-01 23:35:15 +01:00
|
|
|
eleventyConfig.addDataExtension('yml, yaml', (contents) =>
|
|
|
|
yaml.load(contents),
|
|
|
|
);
|
2023-01-24 23:51:07 +01:00
|
|
|
|
2023-01-27 18:20:05 +01:00
|
|
|
// Paired shortcodes...
|
2023-01-24 23:51:07 +01:00
|
|
|
eleventyConfig.addPairedLiquidShortcode('markdown', (content) =>
|
2023-02-01 23:42:31 +01:00
|
|
|
mdown.render(content),
|
2023-01-24 23:51:07 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
eleventyConfig.addPairedLiquidShortcode('markdownInline', (content) =>
|
2023-02-01 23:42:31 +01:00
|
|
|
mdown.renderInline(content),
|
2023-01-24 23:51:07 +01:00
|
|
|
);
|
|
|
|
|
2023-01-31 23:05:27 +01:00
|
|
|
eleventyConfig.addPairedLiquidShortcode('typogr', (content) =>
|
|
|
|
typogrify.typogrify(content),
|
|
|
|
);
|
|
|
|
|
2023-01-27 18:26:46 +01:00
|
|
|
// Filters...
|
2023-01-27 18:25:28 +01:00
|
|
|
eleventyConfig.addLiquidFilter('formatDistanceToNow', (date) => {
|
|
|
|
return formatDistanceToNow(new Date(date));
|
2023-01-26 21:56:20 +01:00
|
|
|
});
|
|
|
|
|
2023-01-27 18:20:05 +01:00
|
|
|
eleventyConfig.addLiquidFilter('markdown', (content) =>
|
2023-02-01 23:42:31 +01:00
|
|
|
mdown.render(content),
|
2023-01-27 18:20:05 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
eleventyConfig.addLiquidFilter('markdownInline', (content) =>
|
2023-02-01 23:42:31 +01:00
|
|
|
mdown.renderInline(content),
|
2023-01-27 18:20:05 +01:00
|
|
|
);
|
|
|
|
|
2023-01-24 23:51:07 +01:00
|
|
|
eleventyConfig.addLiquidFilter('typogr', (content) =>
|
|
|
|
typogrify.typogrify(content),
|
|
|
|
);
|
|
|
|
|
|
|
|
eleventyConfig.addLiquidFilter('isTypedoc', (page) =>
|
|
|
|
page.url.startsWith('/documentation/js-api/'),
|
|
|
|
);
|
|
|
|
|
2023-01-29 21:04:56 +01:00
|
|
|
eleventyConfig.addPlugin(EleventyRenderPlugin);
|
|
|
|
|
2023-01-06 23:37:45 +01:00
|
|
|
// settings
|
|
|
|
return {
|
|
|
|
dir: {
|
2023-01-09 20:10:02 +01:00
|
|
|
input: 'source',
|
|
|
|
includes: '_includes',
|
|
|
|
layouts: '_layouts',
|
2023-01-06 23:37:45 +01:00
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|