mirror of
https://github.com/withastro/astro.git
synced 2025-01-13 22:11:20 -05:00
feb88afb8c
* fix: improve docs example * final touches * chore: prettier * lockfile * ci? * downgrade types node * fresh lockfile * lockfile and npmrc * remove debug log * Merge branch 'main' into docs-template-ts * merging lockfiles suck * update lockfile * satisfy linter
10 lines
404 B
TypeScript
10 lines
404 B
TypeScript
import { KNOWN_LANGUAGES, KNOWN_LANGUAGE_CODES } from './config';
|
|
export { KNOWN_LANGUAGES, KNOWN_LANGUAGE_CODES };
|
|
|
|
export const langPathRegex = /\/([a-z]{2}-?[A-Z]{0,2})\//;
|
|
|
|
export function getLanguageFromURL(pathname: string) {
|
|
const langCodeMatch = pathname.match(langPathRegex);
|
|
const langCode = langCodeMatch ? langCodeMatch[1] : 'en';
|
|
return langCode as typeof KNOWN_LANGUAGE_CODES[number];
|
|
}
|