Skip to content

Commit

Permalink
Merge pull request #230 from diplodoc-platform/route-lang-add-html
Browse files Browse the repository at this point in the history
feat: add lang html extention
  • Loading branch information
makamekm authored Apr 1, 2024
2 parents b2e0450 + 27a3dd0 commit e1fe45e
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e1fe45e

Please sign in to comment.