Refactor codebase

This commit is contained in:
Emil Gulamov 2024-09-08 04:12:44 +04:00
parent 5d7801a777
commit bdcf0dfde9
9 changed files with 7 additions and 34 deletions

View file

@ -74,29 +74,10 @@ import Icon from "./icons/Icon.astro";
// Disable the selection of the same language
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 (
url.pathname.includes("/post") ||
url.pathname.includes("/insight")
url.pathname.includes("/insight") ||
url.pathname.includes("/products")
) {
if (url.pathname.includes("en")) {
pathParts.unshift(lang);

View file

@ -51,5 +51,4 @@ tableData:
blueprints:
first: "@/images/blueprint-1.avif"
second: "@/images/blueprint-2.avif"
slug: a765
---

View file

@ -52,5 +52,4 @@ specificationsRight:
blueprints:
first: "@/images/blueprint-1.avif"
second: "@/images/blueprint-2.avif"
slug: b203
---

View file

@ -52,5 +52,4 @@ specificationsRight:
blueprints:
first: "@/images/blueprint-1.avif"
second: "@/images/blueprint-2.avif"
slug: f303
---

View file

@ -52,5 +52,4 @@ specificationsRight:
blueprints:
first: "@/images/blueprint-1.avif"
second: "@/images/blueprint-2.avif"
slug: t845
---

View file

@ -51,5 +51,4 @@ tableData:
blueprints:
first: "@/images/blueprint-1.avif"
second: "@/images/blueprint-2.avif"
slug: a765-fr
---

View file

@ -52,5 +52,4 @@ specificationsRight:
blueprints:
first: "@/images/blueprint-1.avif"
second: "@/images/blueprint-2.avif"
slug: b203-fr
---

View file

@ -52,5 +52,4 @@ specificationsRight:
blueprints:
first: "@/images/blueprint-1.avif"
second: "@/images/blueprint-2.avif"
slug: f303-fr
---

View file

@ -52,5 +52,4 @@ specificationsRight:
blueprints:
first: "@/images/blueprint-1.avif"
second: "@/images/blueprint-2.avif"
slug: t845-fr
---