From 712db164394976790e29aadf3e6d9c6728d258dc Mon Sep 17 00:00:00 2001 From: madrilene Date: Thu, 7 Nov 2024 07:02:12 +0100 Subject: [PATCH] remove unused filter toAbsoluteUrl and util --- eleventy.config.js | 1 - src/_config/filters.js | 2 -- src/_config/filters/to-absolute-url.js | 12 ------------ src/_config/utils/throw-if-not-type.js | 13 ------------- 4 files changed, 28 deletions(-) delete mode 100644 src/_config/filters/to-absolute-url.js delete mode 100644 src/_config/utils/throw-if-not-type.js diff --git a/eleventy.config.js b/eleventy.config.js index 6ca9490..45a3b00 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -69,7 +69,6 @@ export default async function (eleventyConfig) { eleventyConfig.addFilter('striptags', filters.striptags); eleventyConfig.addFilter('shuffle', filters.shuffleArray); eleventyConfig.addFilter('alphabetic', filters.sortAlphabetically); - eleventyConfig.addFilter('toAbsoluteUrl', filters.toAbsoluteUrl); eleventyConfig.addFilter('slugify', filters.slugifyString); // --------------------- Shortcodes diff --git a/src/_config/filters.js b/src/_config/filters.js index df0a556..1a3fe3c 100644 --- a/src/_config/filters.js +++ b/src/_config/filters.js @@ -4,7 +4,6 @@ import {shuffleArray} from './filters/sort-random.js'; import {sortAlphabetically} from './filters/sort-alphabetic.js'; import {splitlines} from './filters/splitlines.js'; import {striptags} from './filters/striptags.js'; -import {toAbsoluteUrl} from './filters/to-absolute-url.js'; import {slugifyString} from './filters/slugify.js'; export default { @@ -13,7 +12,6 @@ export default { markdownFormat, splitlines, striptags, - toAbsoluteUrl, shuffleArray, sortAlphabetically, slugifyString diff --git a/src/_config/filters/to-absolute-url.js b/src/_config/filters/to-absolute-url.js deleted file mode 100644 index b01e71b..0000000 --- a/src/_config/filters/to-absolute-url.js +++ /dev/null @@ -1,12 +0,0 @@ -import {throwIfNotType} from '../utils/throw-if-not-type.js'; -import {url as site} from '../../_data/meta.js'; - -/** Formats the given string as an absolute url. */ -export const toAbsoluteUrl = url => { - throwIfNotType(url, 'string'); - // Replace trailing slash, e.g., site.com/ => site.com - const siteUrl = site.url.replace(/\/$/, ''); - // Replace starting slash, e.g., /path/ => path/ - const relativeUrl = url.replace(/^\//, ''); - return `${siteUrl}/${relativeUrl}`; -}; diff --git a/src/_config/utils/throw-if-not-type.js b/src/_config/utils/throw-if-not-type.js deleted file mode 100644 index 1ed0912..0000000 --- a/src/_config/utils/throw-if-not-type.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Throws an error if the argument is not of the expected type. - * - * @param {*} arg - The argument to check the type of. - * @param {string} expectedType - The expected type of the argument. - * @throws {Error} If the argument is not of the expected type. - */ - -export const throwIfNotType = (arg, expectedType) => { - if (typeof arg !== expectedType) { - throw new Error(`Expected argument of type ${expectedType} but instead got ${arg} (${typeof arg})`); - } -};