fix: lang types

This commit is contained in:
Francesca Giannino
2026-02-25 10:00:30 +01:00
parent 64686198df
commit 29f82a6047
5 changed files with 11 additions and 8 deletions

View File

@@ -7,7 +7,6 @@ import type { HTMLAttributes } from 'astro/types';
export interface LanguageConfig {
code: string;
label: string;
flag?: string;
}
export type LanguageSelectProps = HTMLAttributes<'div'> & {

View File

@@ -1,5 +1,6 @@
---
import type { MenuItem, VersionPrefix } from '@/config/types';
import type { LanguageCode } from '@/i18n/ui';
import SidebarNavItem from './SidebarNavItem.astro';
import {
isLink,
@@ -16,7 +17,7 @@ interface Props {
parentId: string;
sectionIndex: number | null;
currentPath: string;
lang: string;
lang: LanguageCode;
basePath: string;
versioned: VersionPrefix[];
version: string;

View File

@@ -1,6 +1,7 @@
---
import type { Menu, VersionPrefix } from '@/config/types';
import type { VersionConfig } from '@/components/patterns/VersionSwitcher/types';
import type { LanguageCode } from '@/i18n/ui';
import { Body } from '@/components/primitives';
import { Icon } from 'astro-icon/components';
import { VersionSwitcher } from '@/components/patterns';
@@ -19,7 +20,7 @@ interface Props {
menu: Menu;
level: number;
title?: string;
lang: string;
lang: LanguageCode;
currentPath: string;
basePath?: string;
versioned?: VersionPrefix[];

View File

@@ -3,6 +3,7 @@ import type { MenuItem } from '@/config/types';
import { BodyMd } from '@/components/primitives';
import { Icon } from 'astro-icon/components';
import { useTranslations } from '@/i18n/utils';
import type { LanguageCode } from '@/i18n/ui';
interface Props {
item: MenuItem & { href?: string };
@@ -13,7 +14,7 @@ interface Props {
submenuId?: string;
targetLevel?: number;
showIcon?: boolean;
lang: string;
lang: LanguageCode;
}
const {

View File

@@ -1,5 +1,6 @@
import type { Menu, MenuItem, VersionPrefix } from '@/config/types';
import type { VersionConfig } from '@/components/patterns/VersionSwitcher/types';
import type { LanguageCode } from '@/i18n/ui';
export type SubmenuData = {
menu: Menu;
@@ -20,7 +21,7 @@ export function isVersioned(versioned: VersionPrefix[] | undefined, version: str
export function resolveHref(
href: string,
lang: string,
lang: LanguageCode,
basePath: string,
versioned: VersionPrefix[] | undefined,
version: string
@@ -116,7 +117,7 @@ function checkItemsForPath(
normalizedCurrentPath: string,
basePath: string,
versioned: VersionPrefix[] | undefined,
lang: string,
lang: LanguageCode,
version: string
): boolean {
return filterItems(items, version).some((item) => {
@@ -145,7 +146,7 @@ export function submenuContainsCurrentPath(
submenuBasePath: string,
submenuVersioned: VersionPrefix[] | undefined,
currentPath: string,
lang: string,
lang: LanguageCode,
version: string
): boolean {
const normalizedCurrentPath = normalizePath(currentPath);
@@ -179,7 +180,7 @@ export function submenuContainsCurrentPath(
export function calculateInitialActiveLevel(
submenus: SubmenuData[],
currentPath: string,
lang: string,
lang: LanguageCode,
version: string
): number {
return submenus.reduce((maxLevel, submenu) => {