@clazic/urban 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ // router.js — SPA 라우팅 진입점
2
+ // 실제 navigateTo / popstate 로직은 app.js window.app에 위치.
3
+ // 이 파일은 향후 app.js에서 라우팅 코드를 분리할 때 사용하는 placeholder.
4
+
5
+ // 모든 <a href="/..."> 클릭을 가로채서 SPA 네비게이션으로 전환
6
+ document.addEventListener('click', (e) => {
7
+ const a = e.target.closest('a[href]');
8
+ if (!a) return;
9
+ const href = a.getAttribute('href');
10
+ if (!href || href.startsWith('http') || href.startsWith('#') || href.startsWith('mailto:')) return;
11
+ if (window.app?.navigateTo) {
12
+ e.preventDefault();
13
+ window.app.navigateTo(href);
14
+ }
15
+ });