返回 AiToEarn
routeUtils.ts
根目录 / project / aitoearn-web / src / app / layout / shared / utils / routeUtils.ts
1 /**
2 * route - route helper functions
3 */
4
5 import { languages } from '@/app/i18n/settings'
6
7 const PUBLIC_PATHS = [
8 '/auth',
9 '/websit',
10 '/blog',
11 '/chat',
12 '/welcome',
13 ]
14
15 function getPathWithoutLanguagePrefix(pathname: string) {
16 let path = pathname
17 for (const lang of languages) {
18 if (pathname === `/${lang}` || pathname.startsWith(`/${lang}/`)) {
19 path = pathname.slice(lang.length + 1) || '/'
20 break
21 }
22 }
23
24 return path
25 }
26
27 export function isPublicPage(pathname: string): boolean {
28 const path = getPathWithoutLanguagePrefix(pathname)
29
30 if (path === '/' || path === '') {
31 return true
32 }
33
34 return PUBLIC_PATHS.some(publicPath => path.startsWith(publicPath))
35 }
36
36 lines TYPESCRIPT