astro-ghostcms/.pnpm-store/v3/files/19/af3ae8e5625f42858db21b91e7e...

79 lines
2.6 KiB
Plaintext

import type { AstroConfig, Locales } from '../@types/astro.js';
import type { RoutingStrategies } from '../core/config/schema.js';
type GetLocaleRelativeUrl = GetLocaleOptions & {
locale: string;
base: string;
locales: Locales;
trailingSlash: AstroConfig['trailingSlash'];
format: AstroConfig['build']['format'];
routing?: RoutingStrategies;
defaultLocale: string;
};
export type GetLocaleOptions = {
/**
* Makes the locale URL-friendly by replacing underscores with dashes, and converting the locale to lower case.
* @default true
*/
normalizeLocale?: boolean;
/**
* An optional path to add after the `locale`.
*/
path?: string;
/**
* An optional path to prepend to `locale`.
*/
prependWith?: string;
};
type GetLocaleAbsoluteUrl = GetLocaleRelativeUrl & {
site: AstroConfig['site'];
};
/**
* The base URL
*/
export declare function getLocaleRelativeUrl({ locale, base, locales: _locales, trailingSlash, format, path, prependWith, normalizeLocale, routing, defaultLocale, }: GetLocaleRelativeUrl): string;
/**
* The absolute URL
*/
export declare function getLocaleAbsoluteUrl({ site, ...rest }: GetLocaleAbsoluteUrl): string;
type GetLocalesBaseUrl = GetLocaleOptions & {
base: string;
locales: Locales;
trailingSlash: AstroConfig['trailingSlash'];
format: AstroConfig['build']['format'];
routing?: RoutingStrategies;
defaultLocale: string;
};
export declare function getLocaleRelativeUrlList({ base, locales: _locales, trailingSlash, format, path, prependWith, normalizeLocale, routing, defaultLocale, }: GetLocalesBaseUrl): string[];
export declare function getLocaleAbsoluteUrlList({ site, ...rest }: GetLocaleAbsoluteUrl): string[];
/**
* Given a locale (code), it returns its corresponding path
* @param locale
* @param locales
*/
export declare function getPathByLocale(locale: string, locales: Locales): string | undefined;
/**
* An utility function that retrieves the preferred locale that correspond to a path.
*
* @param path
* @param locales
*/
export declare function getLocaleByPath(path: string, locales: Locales): string | undefined;
/**
*
* Given a locale, this function:
* - replaces the `_` with a `-`;
* - transforms all letters to be lower case;
*/
export declare function normalizeTheLocale(locale: string): string;
/**
* Returns an array of only locales, by picking the `code`
* @param locales
*/
export declare function toCodes(locales: Locales): string[];
/**
* It returns the array of paths
* @param locales
*/
export declare function toPaths(locales: Locales): string[];
export {};