diff --git a/.eleventy.js b/.eleventy.js index 6f5c0812..fa9e4d74 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -4,9 +4,8 @@ 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 { copy404Page, minifyJsComponents } from './config/events/index.js' +import { copyErrorPages } from './config/events/index.js' import { popularPosts, processContent } from './config/collections/index.js' import { DateTime } from 'luxon' @@ -91,32 +90,8 @@ 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', copy404Page) - eleventyConfig.on('afterBuild', minifyJsComponents) + eleventyConfig.on('afterBuild', copyErrorPages) return { passthroughFileCopy: true, diff --git a/config/events/index.js b/config/events/index.js index 52c0c72b..c5a509f0 100644 --- a/config/events/index.js +++ b/config/events/index.js @@ -1,26 +1,30 @@ import fs from 'fs' import path from 'path' -import { minify } from 'terser' -export const minifyJsComponents = async () => { - const jsComponentsDir = '_site/assets/scripts/components'; - const files = fs.readdirSync(jsComponentsDir); - for (const fileName of files) { - if (fileName.endsWith('.js')) { - const filePath = `${jsComponentsDir}/${fileName}`; - const minified = await minify(fs.readFileSync(filePath, 'utf8')); - fs.writeFileSync(filePath, minified.code); - } else { - console.log('⚠ No js components found') - } - } -} +const errorPages = ['404', '500', '1000', 'broken', 'error', 'js-challenge', 'not-allowed', 'rate-limit'] -export const copy404Page = () => { - const sourcePath = path.join('_site', '404', 'index.html') - const destinationPath = path.join('_site', '404.html') +export const copyErrorPages = () => { + errorPages.forEach((errorPage) => { + const sourcePath = path.join('_site', errorPage, 'index.html') + const destinationPath = path.join('_site', `${errorPage}.html`) + const directoryPath = path.join('_site', errorPage) - fs.copyFile(sourcePath, destinationPath, (err) => { - if (err) console.error('Error copying 404 page:', err) + fs.copyFile(sourcePath, destinationPath, (err) => { + if (err) { + console.error(`Error copying ${errorPage} page:`, err) + return + } + + fs.unlink(sourcePath, (unlinkErr) => { + if (unlinkErr) { + console.error(`Error deleting source file for ${errorPage} page:`, unlinkErr) + return + } + + fs.rmdir(directoryPath, (rmdirErr) => { + if (rmdirErr) console.error(`Error removing directory for ${errorPage} page:`, rmdirErr) + }) + }) + }) }) -} \ No newline at end of file +} diff --git a/package-lock.json b/package-lock.json index 01b4604f..7fa7ffe2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "coryd.dev", - "version": "21.3.8", + "version": "21.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "coryd.dev", - "version": "21.3.8", + "version": "21.4.0", "license": "MIT", "dependencies": { "@cdransf/api-text": "^1.4.0", @@ -23,15 +23,13 @@ "@cdransf/eleventy-plugin-tabler-icons": "^1.10.0", "@supabase/supabase-js": "^2.45.0", "dotenv-flow": "^4.1.0", - "html-minifier-terser": "^7.2.0", "liquidjs": "^10.16.1", "luxon": "^3.5.0", "markdown-it": "^14.1.0", "markdown-it-anchor": "^9.0.1", "markdown-it-footnote": "^4.0.0", "sanitize-html": "^2.13.0", - "slugify": "^1.6.6", - "terser": "^5.31.3" + "slugify": "^1.6.6" } }, "node_modules/@11ty/dependency-tree": { @@ -326,70 +324,6 @@ "node": ">=12" } }, - "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", - "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/set-array": "^1.2.1", - "@jridgewell/sourcemap-codec": "^1.4.10", - "@jridgewell/trace-mapping": "^0.3.24" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/set-array": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", - "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/source-map": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.6.tgz", - "integrity": "sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.25" - } - }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", - "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.25", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", - "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/resolve-uri": "^3.1.0", - "@jridgewell/sourcemap-codec": "^1.4.14" - } - }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -857,13 +791,6 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, - "node_modules/buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "dev": true, - "license": "MIT" - }, "node_modules/call-bind": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", @@ -884,21 +811,10 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/camel-case": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz", - "integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==", - "dev": true, - "license": "MIT", - "dependencies": { - "pascal-case": "^3.1.2", - "tslib": "^2.0.3" - } - }, "node_modules/caniuse-lite": { - "version": "1.0.30001647", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001647.tgz", - "integrity": "sha512-n83xdNiyeNcHpzWY+1aFbqCK7LuLfBricc4+alSQL2Xb6OR3XpnQAmlDG+pQcdTfiHRuLcQ96VOfrPSGiNJYSg==", + "version": "1.0.30001649", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001649.tgz", + "integrity": "sha512-fJegqZZ0ZX8HOWr6rcafGr72+xcgJKI9oWfDW5DrD7ExUtgZC7a7R7ZYmZqplh7XDocFdGeIFn7roAxhOeYrPQ==", "dev": true, "funding": [ { @@ -948,19 +864,6 @@ "fsevents": "~2.3.2" } }, - "node_modules/clean-css": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.3.tgz", - "integrity": "sha512-D5J+kHaVb/wKSFcyyV75uCn8fiY4sV38XJoe4CUyGQ+mOU/fMVYUdH1hJC+CJQ5uY3EnW27SbJYS4X8BiLrAFg==", - "dev": true, - "license": "MIT", - "dependencies": { - "source-map": "~0.6.0" - }, - "engines": { - "node": ">= 10.0" - } - }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -1202,17 +1105,6 @@ "url": "https://github.com/fb55/domutils?sponsor=1" } }, - "node_modules/dot-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", - "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", - "dev": true, - "license": "MIT", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, "node_modules/dotenv": { "version": "16.4.5", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", @@ -1831,28 +1723,6 @@ "node": ">= 0.4" } }, - "node_modules/html-minifier-terser": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/html-minifier-terser/-/html-minifier-terser-7.2.0.tgz", - "integrity": "sha512-tXgn3QfqPIpGl9o+K5tpcj3/MN4SfLtsx2GWwBC3SSd0tXQGyF3gsSqad8loJgKZGM3ZxbYDd5yhiBIdWpmvLA==", - "dev": true, - "license": "MIT", - "dependencies": { - "camel-case": "^4.1.2", - "clean-css": "~5.3.2", - "commander": "^10.0.0", - "entities": "^4.4.0", - "param-case": "^3.0.4", - "relateurl": "^0.2.7", - "terser": "^5.15.1" - }, - "bin": { - "html-minifier-terser": "cli.js" - }, - "engines": { - "node": "^14.13.1 || >=16.0.0" - } - }, "node_modules/htmlparser2": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-7.2.0.tgz", @@ -2400,16 +2270,6 @@ "dev": true, "license": "MIT" }, - "node_modules/lower-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", - "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", - "dev": true, - "license": "MIT", - "dependencies": { - "tslib": "^2.0.3" - } - }, "node_modules/lru-cache": { "version": "10.4.3", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", @@ -2618,17 +2478,6 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, - "node_modules/no-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", - "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", - "dev": true, - "license": "MIT", - "dependencies": { - "lower-case": "^2.0.2", - "tslib": "^2.0.3" - } - }, "node_modules/node-fetch": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", @@ -2810,17 +2659,6 @@ "dev": true, "license": "BlueOak-1.0.0" }, - "node_modules/param-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz", - "integrity": "sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==", - "dev": true, - "license": "MIT", - "dependencies": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, "node_modules/parse-srcset": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/parse-srcset/-/parse-srcset-1.0.2.tgz", @@ -2838,17 +2676,6 @@ "node": ">= 0.8" } }, - "node_modules/pascal-case": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz", - "integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==", - "dev": true, - "license": "MIT", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -3089,16 +2916,6 @@ "node": ">=8.10.0" } }, - "node_modules/relateurl": { - "version": "0.2.7", - "resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz", - "integrity": "sha512-G08Dxvm4iDN3MLM0EsP62EDV9IuhXPR6blNz6Utcp7zyV3tr4HVNINt6MpaRWbxoOHT3Q7YN2P+jaHX8vUbgog==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.10" - } - }, "node_modules/reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", @@ -3421,16 +3238,6 @@ "node": ">=8.0.0" } }, - "node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/source-map-js": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz", @@ -3441,17 +3248,6 @@ "node": ">=0.10.0" } }, - "node_modules/source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "dev": true, - "license": "MIT", - "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -3596,32 +3392,6 @@ "node": ">=0.10.0" } }, - "node_modules/terser": { - "version": "5.31.3", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.31.3.tgz", - "integrity": "sha512-pAfYn3NIZLyZpa83ZKigvj6Rn9c/vd5KfYGX7cN1mnzqgDcxWvrU5ZtAfIKhEXz9nRecw4z3LXkjaq96/qZqAA==", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "@jridgewell/source-map": "^0.3.3", - "acorn": "^8.8.2", - "commander": "^2.20.0", - "source-map-support": "~0.5.20" - }, - "bin": { - "terser": "bin/terser" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/terser/node_modules/commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true, - "license": "MIT" - }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -3652,13 +3422,6 @@ "dev": true, "license": "MIT" }, - "node_modules/tslib": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", - "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==", - "dev": true, - "license": "0BSD" - }, "node_modules/uc.micro": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", diff --git a/package.json b/package.json index 4c35f451..4734f8c3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "21.3.8", + "version": "21.4.0", "description": "The source for my personal site. Built using 11ty (and other tools).", "type": "module", "scripts": { @@ -38,14 +38,12 @@ "@cdransf/eleventy-plugin-tabler-icons": "^1.10.0", "@supabase/supabase-js": "^2.45.0", "dotenv-flow": "^4.1.0", - "html-minifier-terser": "^7.2.0", "liquidjs": "^10.16.1", "luxon": "^3.5.0", "markdown-it": "^14.1.0", "markdown-it-anchor": "^9.0.1", "markdown-it-footnote": "^4.0.0", "sanitize-html": "^2.13.0", - "slugify": "^1.6.6", - "terser": "^5.31.3" + "slugify": "^1.6.6" } } diff --git a/src/data/pages.js b/src/data/pages.js index 36bd23b8..a48be435 100644 --- a/src/data/pages.js +++ b/src/data/pages.js @@ -98,7 +98,6 @@ export default async function () { fetchAllPages(), fetchAllBlocks() ]) - return await processPages(pages, blocksByPageId) } catch (error) { console.error('Error fetching and processing pages:', error) diff --git a/src/includes/base.liquid b/src/includes/base.liquid index 48aa535f..9c9ea7ef 100644 --- a/src/includes/base.liquid +++ b/src/includes/base.liquid @@ -39,6 +39,8 @@ {%- assign pageDescription = show.review | markdown | strip_html | default: show.description | truncate: 300 -%} {%- elsif genre.description -%} {%- assign pageDescription = genre.description | markdown | strip_html | truncate: 300 -%} +{%- elsif page.description -%} + {%- assign pageDescription = page.description -%} {%- elsif description -%} {%- assign pageDescription = description -%} {%- endif -%} @@ -84,8 +86,8 @@ - - + + diff --git a/src/pages/dynamic/page.html b/src/pages/dynamic/page.html index bde9bc24..75960c76 100644 --- a/src/pages/dynamic/page.html +++ b/src/pages/dynamic/page.html @@ -4,7 +4,7 @@ pagination: data: pages size: 1 alias: page -description: "{{ page.description | default: globals.site_description }}" +description: "{{ page.description }}" permalink: "{{ page.permalink }}/index.html" image: "{{ page.open_graph_image | prepend: 'https://cdn.coryd.dev/' | default: globals.meta_data.opengraph_default }}" updated: {{ page.updated | default: null }}