mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-17 16:00:50 -04:00
20 lines
651 B
TypeScript
20 lines
651 B
TypeScript
import { WindowLocation } from '@reach/router';
|
|
import { i18nConstants } from '../../../shared/config/constants';
|
|
|
|
const splitPath = (pathname: string): string[] =>
|
|
pathname.split('/').filter(x => x);
|
|
|
|
export const isLanding = (pathname: string): boolean => {
|
|
const pathArray = splitPath(pathname);
|
|
const isEnglishLanding = pathArray.length === 0;
|
|
const isI18Landing =
|
|
pathArray.length === 1 && i18nConstants.includes(pathArray[0]);
|
|
return isEnglishLanding || isI18Landing;
|
|
};
|
|
|
|
export const isLocationSuperBlock = (
|
|
location: WindowLocation | undefined
|
|
): boolean => {
|
|
return /^\/learn\/[\w-]+\/$/.test(location?.pathname ?? '');
|
|
};
|