gc-guide/src/utils/navigation.ts

35 lines
1.3 KiB
TypeScript
Raw Normal View 히스토리

import type { NavItem } from '../types';
export const DEV_NAV: NavItem[] = [
{ path: '/dev/env-intro', label: '개발환경 소개' },
{ path: '/dev/initial-setup', label: '초기 환경 설정' },
{ path: '/dev/gitea-usage', label: 'Gitea 사용법' },
{ path: '/dev/git-workflow', label: 'Git 워크플로우' },
{ path: '/dev/starting-project', label: '프로젝트 시작하기' },
{ path: '/dev/nexus-usage', label: 'Nexus 사용법' },
{ path: '/dev/ci-cd', label: 'CI/CD 자동 배포' },
{ path: '/dev/chat-bot', label: 'Chat 봇 연동' },
{ path: '/dev/design-system', label: '디자인 시스템' },
];
export const ADMIN_NAV: NavItem[] = [
{ path: '/admin/users', label: '사용자 관리' },
{ path: '/admin/roles', label: '롤 관리' },
{ path: '/admin/permissions', label: '권한 관리' },
{ path: '/admin/settings', label: '설정' },
{ path: '/admin/stats', label: '통계' },
];
export function canAccessPath(path: string, urlPatterns: string[]): boolean {
return urlPatterns.some((pattern) => matchAntPattern(pattern, path));
}
function matchAntPattern(pattern: string, path: string): boolean {
if (pattern === '/**') return true;
const regex = pattern
.replace(/\*\*/g, '.*')
.replace(/(?<!\.)(\*)/g, '[^/]*')
.replace(/\?/g, '[^/]');
return new RegExp(`^${regex}$`).test(path);
}