diff --git a/eleventy.config.js b/eleventy.config.js index 82a950d..1eefaaa 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -1,6 +1,7 @@ +import { env } from 'node:process'; import eleventyPluginNavigation from '@11ty/eleventy-navigation'; import eleventyPluginWebc from '@11ty/eleventy-plugin-webc'; -import { eleventyImagePlugin } from '@11ty/eleventy-img'; +import Image, { eleventyImagePlugin } from '@11ty/eleventy-img'; import htmlminifier from 'html-minifier-terser'; const IMAGE_TRANSFORM_OPTS = { @@ -18,6 +19,25 @@ const IMAGE_TRANSFORM_OPTS = { } }; +const BASE = env.ELEVENTY_PRODUCTION ? 'https://ref.sebin-nyshkim.net' : 'http://localhost:8080'; + +// source: https://notes.jays.net/blog/11ty/ +async function getOgImage(src, key) { + const stats = await Image(src, { + width: [1200], + formats: ['webp'], + urlPath: '/img/', + outputDir: './public/img/', + filenameFormat: (hash, src, width, format) => `${hash}-${width}.${format}` + }); + + if (key === 'url') { + return BASE + stats.webp[0][key]; + } + + return stats.webp[0][key]; +} + export default async function (eleventyConfig) { eleventyConfig.addWatchTarget('./src/css/'); eleventyConfig.addPassthroughCopy('./src/fonts/'); @@ -32,10 +52,11 @@ export default async function (eleventyConfig) { collection.getFilteredByGlob('./src/jarek/*.md') ); + eleventyConfig.addGlobalData('base', BASE); + eleventyConfig.addTransform('minhtml', function (content) { if ((this.page.outputPath || '').endsWith('.html')) { return htmlminifier.minify(content, { - // keepClosingSlash: true, removeEmptyElements: true, collapseWhitespace: true, ignoreCustomFragments: [ @@ -47,6 +68,8 @@ export default async function (eleventyConfig) { } }); + eleventyConfig.addFilter('getOgImage', getOgImage); + eleventyConfig.addPlugin(eleventyPluginWebc, { components: ['src/components/**/*.webc', 'npm:@11ty/eleventy-img/*.webc'], useTransform: false diff --git a/src/components/head/page-head-meta.webc b/src/components/head/page-head-meta.webc new file mode 100644 index 0000000..f682883 --- /dev/null +++ b/src/components/head/page-head-meta.webc @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/img/jarek/og.png b/src/img/jarek/og.png new file mode 100644 index 0000000..c22cde4 Binary files /dev/null and b/src/img/jarek/og.png differ diff --git a/src/img/og.png b/src/img/og.png new file mode 100644 index 0000000..3552dc7 Binary files /dev/null and b/src/img/og.png differ diff --git a/src/img/sebin/og.png b/src/img/sebin/og.png new file mode 100644 index 0000000..59f1d42 Binary files /dev/null and b/src/img/sebin/og.png differ diff --git a/src/img/viktor/og.png b/src/img/viktor/og.png new file mode 100644 index 0000000..3a16c36 Binary files /dev/null and b/src/img/viktor/og.png differ diff --git a/src/index.11tydata.js b/src/index.11tydata.js index 5340c1d..1bd0048 100644 --- a/src/index.11tydata.js +++ b/src/index.11tydata.js @@ -2,5 +2,7 @@ export default { eleventyNavigation: { key: "Home" }, - layout: 'base.webc' + layout: 'base.webc', + language: 'en_US', + description: 'Your go to place to learn all about the characters of Sebin!' }; diff --git a/src/jarek/jarek.11tydata.json b/src/jarek/jarek.11tydata.json index fef0867..11f06a4 100644 --- a/src/jarek/jarek.11tydata.json +++ b/src/jarek/jarek.11tydata.json @@ -1,3 +1,4 @@ { - "layout": "character.webc" + "layout": "character.webc", + "language": "en_US" } diff --git a/src/layouts/base.webc b/src/layouts/base.webc index 5e188da..31328a3 100644 --- a/src/layouts/base.webc +++ b/src/layouts/base.webc @@ -3,14 +3,13 @@ - - Choose Your Character! + diff --git a/src/sebin/sebin.11tydata.json b/src/sebin/sebin.11tydata.json index addae86..7dcfbc4 100644 --- a/src/sebin/sebin.11tydata.json +++ b/src/sebin/sebin.11tydata.json @@ -1,5 +1,6 @@ { "layout": "character.webc", + "language": "en_US", "galleryMuscle": [ { "alt": "Sebin looking aloof (but chill)", diff --git a/src/viktor/viktor.11tydata.json b/src/viktor/viktor.11tydata.json index 1af39d0..0e8fc64 100644 --- a/src/viktor/viktor.11tydata.json +++ b/src/viktor/viktor.11tydata.json @@ -1,5 +1,6 @@ { "layout": "character.webc", + "language": "en_US", "jobs": [ { "title": "Bartender",