Refactor codebase
This commit is contained in:
parent
5d7801a777
commit
bdcf0dfde9
9 changed files with 7 additions and 34 deletions
|
@ -74,29 +74,10 @@ import Icon from "./icons/Icon.astro";
|
||||||
// Disable the selection of the same language
|
// Disable the selection of the same language
|
||||||
if (lang === url.pathname.split("/")[1]) return;
|
if (lang === url.pathname.split("/")[1]) return;
|
||||||
|
|
||||||
// If on product detail page, adjust the slug
|
|
||||||
if (url.pathname.includes("/products/")) {
|
|
||||||
let productSlug = pathParts[pathParts.length - 1]; // Get the last part of the URL which is the slug
|
|
||||||
|
|
||||||
if (lang === "fr") {
|
|
||||||
// If switching to French, ensure the slug has "-fr"
|
|
||||||
if (!productSlug.endsWith("-fr")) {
|
|
||||||
productSlug += "-fr";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// If switching to English, remove "-fr" from the slug
|
|
||||||
if (productSlug.endsWith("-fr")) {
|
|
||||||
productSlug = productSlug.replace("-fr", "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the last part of the path with the adjusted slug
|
|
||||||
pathParts[pathParts.length - 1] = productSlug;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
url.pathname.includes("/post") ||
|
url.pathname.includes("/post") ||
|
||||||
url.pathname.includes("/insight")
|
url.pathname.includes("/insight") ||
|
||||||
|
url.pathname.includes("/products")
|
||||||
) {
|
) {
|
||||||
if (url.pathname.includes("en")) {
|
if (url.pathname.includes("en")) {
|
||||||
pathParts.unshift(lang);
|
pathParts.unshift(lang);
|
||||||
|
|
|
@ -51,5 +51,4 @@ tableData:
|
||||||
blueprints:
|
blueprints:
|
||||||
first: "@/images/blueprint-1.avif"
|
first: "@/images/blueprint-1.avif"
|
||||||
second: "@/images/blueprint-2.avif"
|
second: "@/images/blueprint-2.avif"
|
||||||
slug: a765
|
|
||||||
---
|
---
|
||||||
|
|
|
@ -52,5 +52,4 @@ specificationsRight:
|
||||||
blueprints:
|
blueprints:
|
||||||
first: "@/images/blueprint-1.avif"
|
first: "@/images/blueprint-1.avif"
|
||||||
second: "@/images/blueprint-2.avif"
|
second: "@/images/blueprint-2.avif"
|
||||||
slug: b203
|
|
||||||
---
|
---
|
||||||
|
|
|
@ -52,5 +52,4 @@ specificationsRight:
|
||||||
blueprints:
|
blueprints:
|
||||||
first: "@/images/blueprint-1.avif"
|
first: "@/images/blueprint-1.avif"
|
||||||
second: "@/images/blueprint-2.avif"
|
second: "@/images/blueprint-2.avif"
|
||||||
slug: f303
|
|
||||||
---
|
---
|
||||||
|
|
|
@ -52,5 +52,4 @@ specificationsRight:
|
||||||
blueprints:
|
blueprints:
|
||||||
first: "@/images/blueprint-1.avif"
|
first: "@/images/blueprint-1.avif"
|
||||||
second: "@/images/blueprint-2.avif"
|
second: "@/images/blueprint-2.avif"
|
||||||
slug: t845
|
|
||||||
---
|
---
|
||||||
|
|
|
@ -51,5 +51,4 @@ tableData:
|
||||||
blueprints:
|
blueprints:
|
||||||
first: "@/images/blueprint-1.avif"
|
first: "@/images/blueprint-1.avif"
|
||||||
second: "@/images/blueprint-2.avif"
|
second: "@/images/blueprint-2.avif"
|
||||||
slug: a765-fr
|
|
||||||
---
|
---
|
||||||
|
|
|
@ -52,5 +52,4 @@ specificationsRight:
|
||||||
blueprints:
|
blueprints:
|
||||||
first: "@/images/blueprint-1.avif"
|
first: "@/images/blueprint-1.avif"
|
||||||
second: "@/images/blueprint-2.avif"
|
second: "@/images/blueprint-2.avif"
|
||||||
slug: b203-fr
|
|
||||||
---
|
---
|
||||||
|
|
|
@ -52,5 +52,4 @@ specificationsRight:
|
||||||
blueprints:
|
blueprints:
|
||||||
first: "@/images/blueprint-1.avif"
|
first: "@/images/blueprint-1.avif"
|
||||||
second: "@/images/blueprint-2.avif"
|
second: "@/images/blueprint-2.avif"
|
||||||
slug: f303-fr
|
|
||||||
---
|
---
|
||||||
|
|
|
@ -52,5 +52,4 @@ specificationsRight:
|
||||||
blueprints:
|
blueprints:
|
||||||
first: "@/images/blueprint-1.avif"
|
first: "@/images/blueprint-1.avif"
|
||||||
second: "@/images/blueprint-2.avif"
|
second: "@/images/blueprint-2.avif"
|
||||||
slug: t845-fr
|
|
||||||
---
|
---
|
||||||
|
|
Loading…
Add table
Reference in a new issue