diff --git a/.eleventy.js b/.eleventy.js index ffdd4795..de27046c 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -3,6 +3,8 @@ const heroIcons = require('eleventy-plugin-heroicons') const pluginUnfurl = require('eleventy-plugin-unfurl') const pluginFilesMinifier = require('@sherby/eleventy-plugin-files-minifier') const schema = require('@quasibit/eleventy-plugin-schema') +const { eleventyImagePlugin } = require('@11ty/eleventy-img') +const Image = require('@11ty/eleventy-img') const markdownIt = require('markdown-it') const markdownItAnchor = require('markdown-it-anchor') const markdownItFootnote = require('markdown-it-footnote') @@ -21,6 +23,7 @@ module.exports = function (eleventyConfig) { eleventyConfig.addPlugin(pluginUnfurl) eleventyConfig.addPlugin(pluginFilesMinifier) eleventyConfig.addPlugin(schema) + eleventyConfig.addPlugin(eleventyImagePlugin) // tailwind watches eleventyConfig.addWatchTarget('./tailwind.config.js') @@ -89,9 +92,24 @@ module.exports = function (eleventyConfig) { return md.render(content) }) - // asset_img shortcode - eleventyConfig.addLiquidShortcode('asset_img', (filename, alt) => { - return `${alt}` + // image shortcode + eleventyConfig.addShortcode('image', async function (src, alt, css, sizes, loading) { + let metadata = await Image(src, { + widths: [75, 150, 300, 600], + formats: ['webp'], + urlPath: '/assets/img/cache/', + outputDir: './_site/assets/img/cache/', + }) + + let imageAttributes = { + class: css, + alt, + sizes, + loading: loading || 'lazy', + decoding: 'async', + } + + return Image.generateHTML(metadata, imageAttributes) }) return { diff --git a/config/mediaFilters.js b/config/mediaFilters.js index 25d8b984..38fd9c37 100644 --- a/config/mediaFilters.js +++ b/config/mediaFilters.js @@ -2,7 +2,7 @@ const ALBUM_DENYLIST = ['no-love-deep-web', 'unremittance'] module.exports = { artist: (media) => - `https://cdn.coryd.dev/artists/min/${media.replace(/\s+/g, '-').toLowerCase()}.webp`, + `https://cdn.coryd.dev/artists/${media.replace(/\s+/g, '-').toLowerCase()}.jpg`, album: (media) => { return !ALBUM_DENYLIST.includes(media.name.replace(/\s+/g, '-').toLowerCase()) ? media.image[media.image.length - 1]['#text'].replace( @@ -11,8 +11,7 @@ module.exports = { ) : `https://cdn.coryd.dev/albums/${media.name.replace(/\s+/g, '-').toLowerCase()}.jpg` }, - tv: (episode) => - `https://cdn.coryd.dev/tv/min/${episode.replace(/\s+/g, '-').toLowerCase()}.webp`, + tv: (episode) => `https://cdn.coryd.dev/tv/${episode.replace(/\s+/g, '-').toLowerCase()}.jpg`, movie: (url, host, cdn) => { return url.replace(host, cdn).replace('600', '200').replace('900', '300') }, diff --git a/src/_includes/now.liquid b/src/_includes/now.liquid index cb0f0c5f..215d3bec 100644 --- a/src/_includes/now.liquid +++ b/src/_includes/now.liquid @@ -55,13 +55,9 @@ layout: main {{ artist.playcount }} plays - {{artist.name | escape}} + {%- capture artistImg %}{{ artist.name | artist }}{% endcapture -%} + {%- capture artistName %}{{ artist.name | escape }}{% endcapture -%} + {% image artistImg, artistName, 'rounded-lg', '225px', 'eager' %} {% endfor %} @@ -84,14 +80,9 @@ layout: main {{ album.artist.name }} - {{album.name | escape}} + {%- capture albumImg %}{{ album | album }}{% endcapture -%} + {%- capture albumName %}{{ album.name | escape }}{% endcapture -%} + {% image albumImg, albumName, 'rounded-lg', '225px' %} {% endfor %} @@ -143,14 +134,9 @@ layout: main
{{ movie.title }}
- {{movie.title | escape}} + {%- capture movieImg %}{{movie.image | movie: site.letterboxd-host, site.cdn-movies}}{% endcapture -%} + {%- capture movieName %}{{movie.title | escape}}{% endcapture -%} + {% image movieImg, movieName, 'rounded-lg w-full', '180px' %} {% endfor %} @@ -173,14 +159,9 @@ layout: main {{ episode.show.title }} • S{{ episode.episode.season }}E{{ episode.episode.number }} - {{ episode.episode.title | escape}} {{ episode.show.title | escape }} + {%- capture tvImg %}{{episode.show.title | tv}}{% endcapture -%} + {%- capture tvName %}{{ episode.episode.title | escape}} {{ episode.show.title | escape }}{% endcapture -%} + {% image tvImg, tvName, 'rounded-lg w-full', '180px' %} {% endfor %} diff --git a/src/_includes/webmentions.liquid b/src/_includes/webmentions.liquid index 645e0c05..786574cd 100644 --- a/src/_includes/webmentions.liquid +++ b/src/_includes/webmentions.liquid @@ -8,11 +8,7 @@ {% for mention in mentions['repost-of'] %}
  • - {{mention.author.name}} + {% image mention.author.photo, mention.author.name, 'bg-gray-900 dark:bg-white h-14 w-14 rounded-full border-4 border-white dark:border-gray-900 transition-all hover:border-purple-500 dark:hover:border-purple-400', '56px' %}
  • {% endfor %} @@ -26,11 +22,7 @@ {% for mention in mentions['like-of'] %}
  • - {{mention.author.name}} + {% image mention.author.photo, mention.author.name, 'bg-gray-900 dark:bg-white h-14 w-14 rounded-full border-4 border-white dark:border-gray-900 transition-all hover:border-purple-500 dark:hover:border-purple-400', '56px' %}
  • {% endfor %} @@ -43,11 +35,7 @@ {% for mention in mentions['in-reply-to'] %}
    - {{mention.author.name}} + {% image mention.author.photo, mention.author.name, 'bg-gray-900 dark:bg-white h-14 w-14 rounded-full border-4 border-white dark:border-gray-900 transition-all group-hover:border-purple-500 dark:group-hover:border-purple-400', '56px' %}

    {{ mention.content.text }}

    {{ mention.published | isoDateOnly }}

    diff --git a/src/about.md b/src/about.md index 6eaf9425..0d7d5684 100644 --- a/src/about.md +++ b/src/about.md @@ -17,9 +17,8 @@ meta: image: src: https://coryd.dev/assets/img/avatar.webp --- -
    - {{ site.name }} + {% image './src/assets/img/avatar.webp', site.name, 'max-w-xs w-full h-auto mt-0 mb-1', '320px', 'eager' %}

    Hi, I'm Cory