2024-11-26 19:12:21 -08:00
|
|
|
import navigationPlugin from '@11ty/eleventy-navigation';
|
|
|
|
|
import syntaxHighlightingPlugin from '@11ty/eleventy-plugin-syntaxhighlight';
|
2024-11-28 22:12:05 -08:00
|
|
|
import { eleventyImageTransformPlugin } from '@11ty/eleventy-img';
|
2024-11-26 19:12:21 -08:00
|
|
|
import markdownIt from 'markdown-it';
|
|
|
|
|
import tableOfContentsPlugin from '@uncenter/eleventy-plugin-toc';
|
|
|
|
|
import markdownItClass from '@toycode/markdown-it-class';
|
|
|
|
|
import markdownItAnchor from 'markdown-it-anchor';
|
|
|
|
|
import { library, icon } from '@fortawesome/fontawesome-svg-core';
|
|
|
|
|
import { fas } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
|
import { execSync } from 'child_process';
|
2020-08-13 03:29:36 -07:00
|
|
|
|
2024-11-26 19:12:21 -08:00
|
|
|
export default function (eleventyConfig) {
|
2024-06-11 00:51:22 -07:00
|
|
|
eleventyConfig.addPlugin(navigationPlugin);
|
|
|
|
|
eleventyConfig.addPlugin(syntaxHighlightingPlugin);
|
2024-11-28 22:12:05 -08:00
|
|
|
eleventyConfig.addPlugin(eleventyImageTransformPlugin, {
|
|
|
|
|
extensions: 'html',
|
2024-11-30 05:13:22 -08:00
|
|
|
formats: ['webp', 'jpeg', 'png'],
|
2024-11-28 22:12:05 -08:00
|
|
|
widths: ['auto'],
|
|
|
|
|
defaultAttributes: {
|
|
|
|
|
loading: 'lazy',
|
|
|
|
|
decoding: 'async',
|
|
|
|
|
},
|
|
|
|
|
});
|
2020-08-13 03:29:36 -07:00
|
|
|
|
2024-06-11 00:51:22 -07:00
|
|
|
eleventyConfig.addPassthroughCopy('assets');
|
|
|
|
|
eleventyConfig.addPassthroughCopy('fonts');
|
2020-08-13 03:29:36 -07:00
|
|
|
|
2022-07-09 03:52:21 -07:00
|
|
|
// Font Awesome Icons
|
2024-06-11 00:51:22 -07:00
|
|
|
library.add(fas);
|
|
|
|
|
eleventyConfig.addShortcode('fas_icon', function (args) {
|
|
|
|
|
var fas_svg = icon({ prefix: 'fas', iconName: args });
|
|
|
|
|
return `${fas_svg.html}`;
|
2022-07-09 03:52:21 -07:00
|
|
|
});
|
2020-08-13 03:29:36 -07:00
|
|
|
|
2021-07-26 03:07:23 -07:00
|
|
|
const mapping = {
|
2024-06-11 00:51:22 -07:00
|
|
|
h2: 'content-title',
|
|
|
|
|
h3: 'content-title',
|
|
|
|
|
h4: 'content-title',
|
|
|
|
|
h5: 'content-title',
|
|
|
|
|
h6: 'content-title',
|
2021-07-26 03:07:23 -07:00
|
|
|
table: 'table',
|
2024-06-11 00:51:22 -07:00
|
|
|
blockquote: 'alert',
|
2021-07-26 03:07:23 -07:00
|
|
|
};
|
2024-06-11 00:51:22 -07:00
|
|
|
|
2021-08-09 02:59:36 -07:00
|
|
|
const mdOptions = { linkify: false, html: true };
|
2024-06-11 00:51:22 -07:00
|
|
|
const mdAnchorOpts = {
|
2021-08-09 02:59:36 -07:00
|
|
|
permalink: markdownItAnchor.permalink.headerLink(),
|
2024-06-11 00:51:22 -07:00
|
|
|
permalinkClass: 'ml-5',
|
|
|
|
|
permalinkSymbol: '#',
|
|
|
|
|
level: [1, 2, 3, 4],
|
|
|
|
|
};
|
|
|
|
|
|
2021-08-09 02:59:36 -07:00
|
|
|
eleventyConfig.setLibrary(
|
|
|
|
|
'md',
|
2024-06-11 00:51:22 -07:00
|
|
|
markdownIt(mdOptions).use(markdownItClass, mapping).use(markdownItAnchor, mdAnchorOpts),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
eleventyConfig.addPairedShortcode('admonition', function (content, type, title) {
|
|
|
|
|
let titleStr = '';
|
|
|
|
|
if (title) {
|
2023-09-18 08:17:17 -07:00
|
|
|
titleStr = title;
|
2024-06-11 00:51:22 -07:00
|
|
|
} else if (type) {
|
2023-09-18 08:17:17 -07:00
|
|
|
titleStr = type.substring(0, 1).toUpperCase() + type.substring(1).toLowerCase();
|
|
|
|
|
} else {
|
2024-06-11 00:51:22 -07:00
|
|
|
titleStr = 'Info';
|
2023-09-18 08:17:17 -07:00
|
|
|
}
|
2024-06-11 00:51:22 -07:00
|
|
|
|
|
|
|
|
return `<div class="admonition${type ? ` ${type.toLowerCase()}` : ''}">
|
2023-09-18 08:17:17 -07:00
|
|
|
<div class="admonition-title">
|
2024-06-11 00:51:22 -07:00
|
|
|
<span class="admonition-icon${type ? ` ${type.toLowerCase()}` : ''}"></span>
|
2023-09-18 08:17:17 -07:00
|
|
|
${titleStr}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="admonition-content">${content}</div>
|
2024-06-11 00:51:22 -07:00
|
|
|
</div>`;
|
2023-09-18 08:17:17 -07:00
|
|
|
});
|
2023-11-30 13:33:22 -08:00
|
|
|
|
2023-12-11 09:32:09 -08:00
|
|
|
eleventyConfig.addPlugin(tableOfContentsPlugin, {
|
|
|
|
|
tags: ['h2', 'h3'],
|
2024-06-11 00:51:22 -07:00
|
|
|
wrapper: function (toc) {
|
|
|
|
|
toc = toc.replaceAll('<a', "<a class='sidebar-link'");
|
2023-12-11 09:32:09 -08:00
|
|
|
return `${toc}`;
|
2024-06-11 00:51:22 -07:00
|
|
|
},
|
|
|
|
|
});
|
2023-12-11 09:32:09 -08:00
|
|
|
|
2023-11-30 13:33:22 -08:00
|
|
|
eleventyConfig.on('eleventy.after', () => {
|
2024-06-11 00:51:22 -07:00
|
|
|
execSync(`npx pagefind`, { encoding: 'utf-8' });
|
|
|
|
|
});
|
2024-11-26 19:12:21 -08:00
|
|
|
}
|
2024-06-11 00:51:22 -07:00
|
|
|
|
2024-11-26 19:12:21 -08:00
|
|
|
export const config = {
|
|
|
|
|
dir: {
|
|
|
|
|
input: 'content',
|
|
|
|
|
},
|
2024-06-11 00:51:22 -07:00
|
|
|
};
|