diff --git a/workers/dynamic-pages/index.js b/workers/dynamic-pages/index.js index 7697e219..a309ba75 100644 --- a/workers/dynamic-pages/index.js +++ b/workers/dynamic-pages/index.js @@ -1,5 +1,6 @@ import { createClient } from "@supabase/supabase-js"; import { fetchDataByUrl, fetchGlobals } from "./utils/fetchers.js"; +import { minifyHTML } from "./utils/formatters.js"; import { generateArtistHTML, generateBookHTML, @@ -67,7 +68,7 @@ export default { const templateResponse = await fetch(`${BASE_URL}/dynamic`); const template = await templateResponse.text(); const metadata = generateMetadata(data, type, globals); - const html = updateDynamicContent(template, metadata, mediaHtml); + const html = minifyHTML(updateDynamicContent(template, metadata, mediaHtml)); const headers = new Headers({ "Content-Type": "text/html", "Cache-Control": diff --git a/workers/dynamic-pages/utils/formatters.js b/workers/dynamic-pages/utils/formatters.js index 63f540b7..48442b98 100644 --- a/workers/dynamic-pages/utils/formatters.js +++ b/workers/dynamic-pages/utils/formatters.js @@ -17,4 +17,10 @@ md.use(markdownItAnchor, { safariReaderFix: true, }), }); -md.use(markdownItFootnote); \ No newline at end of file +md.use(markdownItFootnote); + +export const minifyHTML = (html) => + html + .replace(/\n\s+/g, "") + .replace(/>\s+<") + .replace(//g, "");