remove unused filter toAbsoluteUrl and util

This commit is contained in:
madrilene 2024-11-07 07:02:12 +01:00
parent b715619708
commit 712db16439
4 changed files with 0 additions and 28 deletions

View file

@ -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

View file

@ -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

View file

@ -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}`;
};

View file

@ -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})`);
}
};