From 27a3dd05c072690ec21f947292cedfe2784dc0ea Mon Sep 17 00:00:00 2001 From: Maxim Karpov Date: Mon, 1 Apr 2024 15:39:01 +0300 Subject: [PATCH] feat: add lang html extention --- src/utils/index.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index 9e0cadb2..1fcf2d9d 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -45,16 +45,12 @@ export function isActiveItem(router: Router, href: string, singlePage?: boolean) return normalizePath(router.pathname) === normalizePath(parse(href).pathname); } -/* -Algorithm: -1. Normalize hash route if it presents -2. Split by "../" and take the last value -5. Join the result -*/ export function getLangPath(router: Router, lang: string) { const path = router.hash ? normalizeHash(router.hash) : normalizePath(router.pathname); const route = path?.split('../') || []; - return `../${lang}/${route[route.length - 1] || ''}`; + const routeLast = route[route.length - 1]; + const routeHtml = routeLast ? routeLast + '.html' : routeLast; + return `../${lang}/${routeHtml || ''}`; } export function isExternalHref(href: string) {