@coffic/cosy-ui 0.9.19 → 0.9.20

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.
@@ -75,16 +75,6 @@ const badgeSize = level === 0 ? 'cosy:badge-sm' : 'cosy:badge-xs';
75
75
  </li>
76
76
 
77
77
  <script>
78
- // 简化的路径匹配函数
79
- function isPathMatch(currentPath: string, href: string): boolean {
80
- if (href === currentPath) return true;
81
- if (href === '/') return currentPath === '/';
82
- if (href.endsWith('/')) {
83
- return currentPath.startsWith(href) || currentPath === href.slice(0, -1);
84
- }
85
- return currentPath.startsWith(href);
86
- }
87
-
88
78
  // 立即处理导航项点击,更新高亮状态
89
79
  document.addEventListener('click', (event) => {
90
80
  const target = event.target as HTMLElement;
@@ -107,45 +97,4 @@ const badgeSize = level === 0 ? 'cosy:badge-sm' : 'cosy:badge-xs';
107
97
  }, 200);
108
98
  }
109
99
  });
110
-
111
- // 处理 Astro 页面切换后的状态恢复
112
- document.addEventListener('astro:page-load', () => {
113
- const currentPath = window.location.pathname;
114
- const allNavItems = document.querySelectorAll(
115
- '[data-sidebar-item]'
116
- ) as NodeListOf<HTMLAnchorElement>;
117
-
118
- // 移除所有高亮状态
119
- allNavItems.forEach((item) => {
120
- item.classList.remove('cosy:menu-active');
121
- });
122
-
123
- // 找到最精确匹配的导航项
124
- let bestMatch: HTMLAnchorElement | null = null;
125
- let bestMatchLength = 0;
126
-
127
- allNavItems.forEach((item) => {
128
- const href = item.getAttribute('data-href');
129
- if (href) {
130
- // 精确匹配优先
131
- if (href === currentPath) {
132
- bestMatch = item;
133
- bestMatchLength = href.length;
134
- }
135
- // 如果没有精确匹配,选择最长的前缀匹配
136
- else if (
137
- currentPath.startsWith(href) &&
138
- href.length > bestMatchLength
139
- ) {
140
- bestMatch = item;
141
- bestMatchLength = href.length;
142
- }
143
- }
144
- });
145
-
146
- // 只高亮最匹配的项
147
- if (bestMatch) {
148
- (bestMatch as HTMLAnchorElement).classList.add('cosy:menu-active');
149
- }
150
- });
151
100
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffic/cosy-ui",
3
- "version": "0.9.19",
3
+ "version": "0.9.20",
4
4
  "description": "An astro component library",
5
5
  "author": {
6
6
  "name": "nookery",