diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a5c9b13..0ddedf6 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -23,7 +23,8 @@ "dbaeumer.vscode-eslint", "astro-build.astro-vscode", "bradlc.vscode-tailwindcss", - "unifiedjs.vscode-mdx" + "unifiedjs.vscode-mdx", + "meganrogge.template-string-converter" ], "settings": { "files.autoSave": "onFocusChange", diff --git a/package-lock.json b/package-lock.json index 094e15b..ef6983e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,12 +13,12 @@ }, "devDependencies": { "@astrojs/check": "0.7.0", - "@astrojs/mdx": "3.0.0", + "@astrojs/mdx": "3.0.1", "@astrojs/tailwind": "5.1.0", "@types/canvas-confetti": "1.6.4", "@typescript-eslint/eslint-plugin": "7.9.0", "@typescript-eslint/parser": "7.9.0", - "astro": "4.8.6", + "astro": "4.9.1", "autoprefixer": "10.4.19", "cross-env": "^7.0.3", "eslint": "8.57.0", @@ -167,9 +167,9 @@ } }, "node_modules/@astrojs/mdx": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@astrojs/mdx/-/mdx-3.0.0.tgz", - "integrity": "sha512-t1x+fmRA7w/AUWEhvWsMjw8op29mkzkpLN+AfsrtIAnGCf5y3NhcDwamKBvHDUTw/SdM3dn0JMi+JGaGnocDmw==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@astrojs/mdx/-/mdx-3.0.1.tgz", + "integrity": "sha512-UcPja14Qt6OEm7Wjak41Qa5f7G1M0oB2ARCsyIkXy6+Z65fJ6c1648UqEOqnEgR6Xtqq+V47wtK2qSP6KQKrAg==", "dev": true, "dependencies": { "@astrojs/markdown-remark": "5.1.0", @@ -2936,11 +2936,10 @@ } }, "node_modules/astro": { - "version": "4.8.6", - "resolved": "https://registry.npmjs.org/astro/-/astro-4.8.6.tgz", - "integrity": "sha512-psHIfK+e+bMPhRwghV9yCGH/uc1jvY4DHmDZdoEepax9yA7kzYH0wt3dpkqlcrO2zxl5jzSC3DmqZfkD6wnW9A==", + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/astro/-/astro-4.9.1.tgz", + "integrity": "sha512-9TsoAu0WBPiqyAIj9H0JW7R+tIjPjFsPKo70Nja6WL3imTTuUJQmnCre4ZVmoNV3oicTTlb+N4zjRYANW0Ty9A==", "dev": true, - "license": "MIT", "dependencies": { "@astrojs/compiler": "^2.8.0", "@astrojs/internal-helpers": "0.4.0", diff --git a/package.json b/package.json index f0a1b74..eadceb5 100644 --- a/package.json +++ b/package.json @@ -22,12 +22,12 @@ }, "devDependencies": { "@astrojs/check": "0.7.0", - "@astrojs/mdx": "3.0.0", + "@astrojs/mdx": "3.0.1", "@astrojs/tailwind": "5.1.0", "@types/canvas-confetti": "1.6.4", "@typescript-eslint/eslint-plugin": "7.9.0", "@typescript-eslint/parser": "7.9.0", - "astro": "4.8.6", + "astro": "4.9.1", "autoprefixer": "10.4.19", "cross-env": "^7.0.3", "eslint": "8.57.0", diff --git a/src/components/Link.astro b/src/components/Link.astro index b3992fe..420df5c 100644 --- a/src/components/Link.astro +++ b/src/components/Link.astro @@ -27,11 +27,20 @@ let extraLinkProps: HTMLAttributes<'a'> = { if (!external) { const baseUrl = `${import.meta.env.BASE_URL}`; + let newHref = baseUrl; + + const hrefStartWithSlash = href.startsWith('/'); + + if (baseUrl === '/') { + newHref = hrefStartWithSlash ? href : `/${href}`; + } else { + const baseUrlEndWithSlash = baseUrl.endsWith('/'); + + newHref = `${baseUrl}${!baseUrlEndWithSlash && !hrefStartWithSlash ? `/` : ''}${href}`; + } + extraLinkProps = { - href: - href === '/' - ? `${baseUrl}` - : `${baseUrl}${!href.startsWith('/') ? '/' : ''}${href}`, + href: newHref, rel: 'prefetch' }; }