diff --git a/.eleventy.js b/.eleventy.js index e369b7ea..1f31aa51 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -109,7 +109,6 @@ export default async function (eleventyConfig) { eleventyConfig.addLiquidFilter(filterName, filters[filterName]) }) eleventyConfig.addLiquidFilter('dateToRfc822', pluginRss.dateToRfc822) - eleventyConfig.addLiquidFilter('absoluteUrl', pluginRss.absoluteUrl) eleventyConfig.addFilter('slugify', slugifyString) // shortcodes diff --git a/config/filters/index.js b/config/filters/index.js index 419d3646..71178239 100644 --- a/config/filters/index.js +++ b/config/filters/index.js @@ -1,6 +1,10 @@ import { DateTime } from 'luxon' import markdownIt from 'markdown-it' import { URL } from 'url' +import { createRequire } from 'module' + +const require = createRequire(import.meta.url) +const metaData = require('../../src/_data/json/meta.json') const utmPattern = /[?&](utm_[^&=]+=[^&#]*)/gi const BASE_URL = 'https://coryd.dev' @@ -90,6 +94,13 @@ export default { if (!url || !posts) return null; return posts[url]?.toots?.[0] || null; }, + absoluteUrl: (url, base) => { + if (!base) base = metaData.url + try { + return (new URL(url, base)).toString() + } catch(e) {} + return url; + }, // feeds normalizeEntries: (entries) => { diff --git a/package.json b/package.json index 37799e81..b26ecdd0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "6.0.3", + "version": "6.0.4", "description": "The source for my personal site. Built using 11ty and hosted on Netlify.", "type": "module", "scripts": { diff --git a/src/_data/json/meta.json b/src/_data/json/meta.json new file mode 100644 index 00000000..9a486b06 --- /dev/null +++ b/src/_data/json/meta.json @@ -0,0 +1,14 @@ +{ + "siteName": "Cory Dransfeldt", + "siteDescription": "I'm a software developer in Camarillo, California. I enjoy hanging out with my beautiful family and 4 rescue dogs, technology, automation, music, writing, reading and tv and movies.", + "author": "Cory Dransfeldt", + "email": "coryd@hey.com", + "url": "https://coryd.dev", + "themeColor": "#3b82f6", + "siteType": "Person", + "locale": "en_US", + "lang": "en", + "meta_data": { + "opengraph_default": "https://coryd.dev/assets/img/logo.webp" + } +} \ No newline at end of file diff --git a/src/_data/meta.js b/src/_data/meta.js index b5196fbc..21116b5f 100644 --- a/src/_data/meta.js +++ b/src/_data/meta.js @@ -1,15 +1,8 @@ -export default { - siteName: 'Cory Dransfeldt', - siteDescription: - "I'm a software developer in Camarillo, California. I enjoy hanging out with my beautiful family and 4 rescue dogs, technology, automation, music, writing, reading and tv and movies.", - author: 'Cory Dransfeldt', - email: 'coryd@hey.com', - url: 'https://coryd.dev', - themeColor: '#3b82f6', - siteType: 'Person', - locale: 'en_US', - lang: 'en', - meta_data: { - opengraph_default: 'https://coryd.dev/assets/img/logo.webp', - }, +import { createRequire } from 'module' + +const require = createRequire(import.meta.url) +const metaData = require('./json/meta.json') + +export default async function () { + return metaData }