chore: restore transforms

This commit is contained in:
Cory Dransfeldt 2024-06-10 09:34:43 -07:00
parent 909008d068
commit 6e366c0fe5
No known key found for this signature in database

View file

@ -4,6 +4,7 @@ import lightningCSS from '@11tyrocks/eleventy-plugin-lightningcss'
import markdownIt from 'markdown-it'
import markdownItAnchor from 'markdown-it-anchor'
import markdownItFootnote from 'markdown-it-footnote'
import htmlmin from 'html-minifier-terser'
import filters from './config/filters/index.js'
import { minifyJsComponents } from './config/events/index.js'
import { allContent, popularPosts, searchIndex } from './config/collections/index.js'
@ -83,6 +84,29 @@ export default async function (eleventyConfig) {
eleventyConfig.addShortcode('appVersion', () => appVersion)
eleventyConfig.addShortcode('currentYear', () => DateTime.now().year)
// transforms
eleventyConfig.addTransform('html-minify', (content, path) => {
if (path && path.endsWith('.html')) {
return htmlmin.minify(content, {
collapseBooleanAttributes: true,
collapseWhitespace: true,
decodeEntities: true,
includeAutoGeneratedTags: false,
minifyCSS: true,
minifyJS: true,
minifyURLs: true,
noNewlinesBeforeTagClose: true,
quoteCharacter: '"',
removeComments: true,
sortAttributes: true,
sortClassName: true,
useShortDoctype: true,
processScripts: ['application/ld+json'], // minify JSON-LD scripts
})
}
return content
})
// events
eleventyConfig.on('afterBuild', minifyJsComponents)