Fix my HTML and integrate prettier

This commit is contained in:
2024-03-29 14:19:01 -05:00
parent 12baf5df2e
commit 779cce9f9d
9 changed files with 102 additions and 65 deletions

View File

@ -7,13 +7,14 @@ const pluginRss = require("@11ty/eleventy-plugin-rss");
const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const pluginBundle = require("@11ty/eleventy-plugin-bundle");
const pluginNavigation = require("@11ty/eleventy-navigation");
const prettier = require("prettier");
const { EleventyHtmlBasePlugin } = require("@11ty/eleventy");
const figoptions = {
figcaption: true
};
module.exports = function(eleventyConfig) {
module.exports = eleventyConfig => {
// Helper Functions
const multiReplace = (text, replacementTable) => {
@ -22,6 +23,15 @@ module.exports = function(eleventyConfig) {
return newText;
};
// Transforms
eleventyConfig.addTransform("prettier", function (content, outputPath) {
if (outputPath && outputPath.endsWith(".html")) {
return prettier.format(content, {parser: "html", bracketSameLine: true, vueIndentScriptAndStyle: true, singleAttributePerLine: true, htmlWhitespaceSensitivity: "ignore"});
} else {
return content;
}
});
eleventyConfig.addWatchTarget("content/**/*.{svg,webp,png,jpeg}");
// Official plugins