Commit ee2b66a

HPCesia <me@hpcesia.com>
2025-01-30 05:33:44
refactor: remove url-utils
1 parent 610b143
Changed files (2)
src
src/components/utils/ImageWrapper.astro
@@ -1,5 +1,4 @@
 ---
-import { url } from '@utils/url-utils';
 import type { ImageMetadata } from 'astro';
 import { Image } from 'astro:assets';
 import path from 'path';
@@ -47,7 +46,7 @@ const imageStyle = `object-position: ${position}`;
   {
     !isLocal && (
       <img
-        src={isPublic ? url(src) : src}
+        src={isPublic ? (new URL(src, Astro.site) as unknown as string) : src}
         alt={alt || ''}
         class={imageClass}
         style={imageStyle}
src/utils/url-utils.ts
@@ -1,22 +0,0 @@
-import i18nKey from '@i18n/I18nKey';
-import { i18n } from '@i18n/translation';
-
-export function pathsEqual(path1: string, path2: string) {
-  const normalizedPath1 = path1.replace(/^\/|\/$/g, '').toLowerCase();
-  const normalizedPath2 = path2.replace(/^\/|\/$/g, '').toLowerCase();
-  return normalizedPath1 === normalizedPath2;
-}
-
-function joinUrl(...parts: string[]): string {
-  const joined = parts.join('/');
-  return joined.replace(/\/+/g, '/');
-}
-
-export function url(path: string) {
-  return joinUrl('', import.meta.env.BASE_URL, path);
-}
-
-export function getCategoryUrl(category: string): string {
-  if (category === i18n(i18nKey.uncategorized)) return url('/archives/category/uncategorized/');
-  return url(`/archives/categories/${category}/1/`);
-}