-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
eleventy.config.cjs
65 lines (53 loc) · 2.26 KB
/
eleventy.config.cjs
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
const SyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const DirectoryOutputPlugin = require('@11ty/eleventy-plugin-directory-output');
const TableOfContentsPlugin = require('eleventy-plugin-toc');
const markdownItAnchor = require('markdown-it-anchor')
const fs = require('fs/promises');
const path = require('path');
module.exports = function(eleventyConfig) {
eleventyConfig.amendLibrary('md', md => md.use(markdownItAnchor));
eleventyConfig.addPlugin(SyntaxHighlight);
eleventyConfig.addPlugin(TableOfContentsPlugin);
eleventyConfig.addPlugin(DirectoryOutputPlugin);
eleventyConfig.addWatchTarget('docs/*.css');
eleventyConfig.addWatchTarget('*.ts');
eleventyConfig.addWatchTarget('lib/*.ts');
eleventyConfig.addPassthroughCopy({
'docs/*.{js,css}': true,
'*.{js,d.ts,map}': 'stripe-elements',
'lib/*.{js,d.ts,map}': 'stripe-elements/lib'
});
eleventyConfig.addShortcode('cem', async function() {
const { customElementsManifestToMarkdown } = await import('@custom-elements-manifest/to-markdown');
const customElementsManifest = JSON.parse(await fs.readFile(path.join(__dirname, 'custom-elements.json')))
const content = customElementsManifestToMarkdown(customElementsManifest, {
headingOffset: 2,
private: 'details',
});
return `<div class="api-table">
${content}
</div>`;
});
eleventyConfig.on('eleventy.before', async function () {
const { execaCommand } = await import('execa');
await execaCommand('npm run build:esbuild');
});
eleventyConfig.addShortcode('sandbox', function(id, args) {
const url = new URL(`/embed/${id}`, 'https://codesandbox.io')
Object.entries({view: 'preview', ...args}).forEach(([key, val]) => url.searchParams.set(key, val));
return `<iframe
src="${url.toString()}"
style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;"
allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>
`;
})
// Return your Object options:
return {
templateEngineOverride: 'njk,md',
dir: {
input: "docs",
output: "_site"
}
}
};