diff --git a/eleventy.config.js b/eleventy.config.js index 3102604..033f72d 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -22,9 +22,24 @@ import markdownItDeflist from 'markdown-it-deflist'; import markdownItFootnote from 'markdown-it-footnote'; import markdownItImageFigures from 'markdown-it-image-figures'; -const MARKDOWNIT_OPTIONS = { html: true, linkify: true, typographer: true }; Image.concurrency = 4; +const urlFormat = ({ src, width, format }) => { + const baseUrl = `https://img.sebin-nyshkim.net/i`; + const imgUuid = src.match(/\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.(\w{3,})/); + const imgFormat = format === 'jpeg' ? 'jpg' : format; + + return `${baseUrl}/${imgUuid[1]}.${imgFormat}?width=${width}`; +}; + +const MARKDOWNIT_OPTIONS = { html: true, linkify: true, typographer: true }; +const ELEVENTY_IMAGE_DEFAULTS = { + formats: ['webp', 'auto'], + urlPath: '/img/', + outputDir: './public/img/', + urlFormat +}; + export default async function (eleventyConfig) { eleventyConfig.addPassthroughCopy('./src/css/prism.css'); eleventyConfig.addWatchTarget('./src/css/'); @@ -32,9 +47,6 @@ export default async function (eleventyConfig) { eleventyConfig.addPassthroughCopy('./src/fonts/'); eleventyConfig.addWatchTarget('./src/fonts/'); - eleventyConfig.addPassthroughCopy('./src/img/sebin.png'); - eleventyConfig.addWatchTarget('./src/img/sebin.png'); - eleventyConfig.addCollection('posts', (collection) => process.env.ELEVENTY_PRODUCTION ? collection.getFilteredByGlob('./src/posts/*.md') @@ -90,13 +102,9 @@ export default async function (eleventyConfig) { } }); eleventyConfig.addPlugin(eleventyImageTransformPlugin, { + ...ELEVENTY_IMAGE_DEFAULTS, extensions: 'html', - formats: ['avif', 'webp', 'auto'], widths: [640, 800, 1280, 1920, 2560, 3840, 'auto'], - sharpJpegOptions: { mozjpeg: true, optimiseScans: true, quality: 95 }, - sharpPngOptions: { compressionLevel: 9 }, - urlPath: '/img/', - outputDir: './public/img/', defaultAttributes: { loading: 'lazy', decoding: 'async', @@ -138,12 +146,8 @@ export default async function (eleventyConfig) { eleventyConfig.addShortcode('year', () => `${new Date().getFullYear()}`); eleventyConfig.addShortcode('bgimgset', async (src) => { const imgset = await Image(src, { + ...ELEVENTY_IMAGE_DEFAULTS, widths: [1920, 2560, 3840], - sharpJpegOptions: { mozjpeg: true, optimiseScans: true, quality: 95 }, - sharpPngOptions: { compressionLevel: 9 }, - formats: ['avif', 'webp', 'auto'], - urlPath: '/img/', - outputDir: './public/img/' }); const getSets = ({ url, sourceType }, i) => `url(${url}) type('${sourceType}') ${i + 1}x`; diff --git a/src/404.md b/src/404.md index e2fa7a3..b098488 100644 --- a/src/404.md +++ b/src/404.md @@ -6,7 +6,7 @@ permalink: /404.html # Here be no dragons -![Sebin is unhappy with the content on his phone](/img/sebin-sticker-phone.png) +![Sebin is unhappy with the content on his phone](https://img.sebin-nyshkim.net/i/00372308-6677-4e84-8344-2630b58f6651) The page you were looking for does not exist! diff --git a/src/about.md b/src/about.md index 166efc4..3beffa9 100644 --- a/src/about.md +++ b/src/about.md @@ -8,7 +8,7 @@ eleventyNavigation: # {{ title }} -![Sebin does a think](/img/sebin-sticker-think.png) +![Sebin does a think](https://img.sebin-nyshkim.net/i/35da87be-0734-4738-9503-07d52c64c905) | Key | Value | | --------- | ----------------- | diff --git a/src/drafts/drafts.json b/src/drafts/drafts.json index 3a003b0..4db5e52 100644 --- a/src/drafts/drafts.json +++ b/src/drafts/drafts.json @@ -6,7 +6,7 @@ "author": { "name": "Sebin Nyshkim", "href": "https://blog.sebin-nyshkim.net", - "image": "https://cdn.sebin-nyshkim.net/-o3c3fVEgEx" + "image": "https://img.sebin-nyshkim.net/i/b6629b72-ab77-4a6c-bf97-b1a615cc2454" }, "twitter": { "cardType": "summary_large_image", diff --git a/src/img/sebin-sticker-hello.png b/src/img/sebin-sticker-hello.png deleted file mode 100644 index 575e05e..0000000 Binary files a/src/img/sebin-sticker-hello.png and /dev/null differ diff --git a/src/img/sebin-sticker-phone.png b/src/img/sebin-sticker-phone.png deleted file mode 100644 index a1af3d1..0000000 Binary files a/src/img/sebin-sticker-phone.png and /dev/null differ diff --git a/src/img/sebin-sticker-think.png b/src/img/sebin-sticker-think.png deleted file mode 100644 index bb6c452..0000000 Binary files a/src/img/sebin-sticker-think.png and /dev/null differ diff --git a/src/img/sebin.png b/src/img/sebin.png deleted file mode 100644 index 8dcce6e..0000000 Binary files a/src/img/sebin.png and /dev/null differ diff --git a/src/index.md b/src/index.md index 7677533..058cab6 100644 --- a/src/index.md +++ b/src/index.md @@ -7,7 +7,7 @@ eleventyNavigation: # Rawr there! 👋🏻 -![Sebin says hello](/img/sebin-sticker-hello.png) +![Sebin says hello](https://img.sebin-nyshkim.net/i/928fab95-ac55-4b66-b876-1c31b5924db6) Welcome to my little corner of the internet! This is where I pour out my thoughts whenever I have them :3 diff --git a/src/layouts/base.njk b/src/layouts/base.njk index 774b306..a9bcdff 100644 --- a/src/layouts/base.njk +++ b/src/layouts/base.njk @@ -29,14 +29,14 @@ {% endif %} - +