@coffic/cosy-ui 0.3.12 → 0.3.33

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.
@@ -54,7 +54,7 @@
54
54
 
55
55
  // 导入样式
56
56
  import '../../app.css';
57
- import { getCurrentLanguage, LanguageSource } from '../../utils/language';
57
+ import { getCurrentLanguage } from '../../utils/language';
58
58
  import { createTextGetter } from '../../utils/i18n';
59
59
 
60
60
  interface Props {
@@ -97,11 +97,6 @@ interface Props {
97
97
  * @default 自动检测
98
98
  */
99
99
  lang?: string;
100
- /**
101
- * 是否启用日志输出
102
- * @default false
103
- */
104
- enableLogging?: boolean;
105
100
  }
106
101
 
107
102
  const {
@@ -113,7 +108,6 @@ const {
113
108
  minHeadings = 2,
114
109
  lang: userLang,
115
110
  title,
116
- enableLogging = true,
117
111
  } = Astro.props;
118
112
 
119
113
  // 获取当前语言
@@ -125,54 +119,28 @@ const titleText = title || t('title');
125
119
 
126
120
  // 生成唯一ID,确保多个TOC实例不会冲突
127
121
  const tocId = `toc-${Math.random().toString(36).substring(2, 9)}`;
128
-
129
- // 获取语言来源的描述
130
- function getLanguageSourceDescription(source: LanguageSource): string {
131
- switch (source) {
132
- case LanguageSource.USER:
133
- return '用户指定';
134
- case LanguageSource.URL:
135
- return 'URL参数';
136
- case LanguageSource.BROWSER:
137
- return '浏览器设置';
138
- case LanguageSource.DEFAULT:
139
- return '默认语言';
140
- default:
141
- return '未知来源';
142
- }
143
- }
144
122
  ---
145
123
 
146
- <div class={`toc-container ${fixed ? 'cosy:fixed cosy:top-20 cosy:right-4 cosy:w-64' : 'cosy:w-full cosy:max-w-xs'} ${className}`} id={`${tocId}-container`} style="display: none;">
147
- <div class="cosy:card cosy:bg-base-100 cosy:shadow-xl">
148
- <div class="cosy:card-body cosy:p-4">
149
- <div class="cosy:card-title cosy:text-lg cosy:font-bold cosy:mb-2">{titleText}</div>
150
- <ul class="cosy:menu cosy:menu-sm" id={tocId}>
151
- <!-- 目录项将通过 JavaScript 动态生成 -->
152
- <li class="cosy:text-base-content/60">{t('loading')}</li>
153
- </ul>
124
+ <aside class:list={[
125
+ 'cosy:hidden cosy:xl:block cosy:w-64 cosy:shrink-0',
126
+ className
127
+ ]}>
128
+ <div class="cosy:top-16 cosy:sticky">
129
+ <div class={`toc-container ${fixed ? 'cosy:w-64' : 'cosy:w-full cosy:max-w-xs'}`} id={`${tocId}-container`} style="display: none;">
130
+ <div class="cosy:bg-base-100 cosy:shadow-xl cosy:card">
131
+ <div class="cosy:p-4 cosy:card-body">
132
+ <div class="cosy:mb-2 cosy:font-bold cosy:text-lg cosy:card-title">{titleText}</div>
133
+ <ul class="cosy:menu cosy:menu-sm" id={tocId}>
134
+ <!-- 目录项将通过 JavaScript 动态生成 -->
135
+ <li class="cosy:text-base-content/60">{t('loading')}</li>
136
+ </ul>
137
+ </div>
138
+ </div>
154
139
  </div>
155
140
  </div>
156
- </div>
157
-
158
- <script define:vars={{ selector, maxDepth, tocId, containerSelector, minHeadings, langInfo, enableLogging }}>
159
- // 输出语言信息到控制台
160
- if (enableLogging) {
161
- console.log(`[TableOfContents] 语言信息:`, {
162
- 语言代码: langInfo.code,
163
- 语言来源: langInfo.source,
164
- 来源描述: (() => {
165
- switch (langInfo.source) {
166
- case 'user': return '用户指定';
167
- case 'url': return 'URL参数';
168
- case 'browser': return '浏览器设置';
169
- case 'default': return '默认语言';
170
- default: return '未知来源';
171
- }
172
- })()
173
- });
174
- }
141
+ </aside>
175
142
 
143
+ <script define:vars={{ selector, maxDepth, tocId, containerSelector, minHeadings, langInfo }}>
176
144
  // 在页面加载完成后生成目录
177
145
  function generateTOC() {
178
146
  // 使用指定的容器选择器查找内容容器
package/dist/index.ts CHANGED
@@ -68,3 +68,5 @@ export { default as Container } from './components/containers/Container.astro';
68
68
  export { default as Main } from './components/containers/Main.astro';
69
69
  export { default as Section } from './components/containers/Section.astro';
70
70
 
71
+ // Types
72
+ export type { SidebarSection } from './types/layout';
@@ -0,0 +1,10 @@
1
+ export interface SidebarItem {
2
+ href: string;
3
+ text: string;
4
+ items?: SidebarItem[];
5
+ }
6
+
7
+ export interface SidebarSection {
8
+ title: string;
9
+ items: SidebarItem[];
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffic/cosy-ui",
3
- "version": "0.3.12",
3
+ "version": "0.3.33",
4
4
  "description": "An astro component library",
5
5
  "author": {
6
6
  "name": "nookery",
@@ -31,10 +31,7 @@
31
31
  "index.ts"
32
32
  ],
33
33
  "scripts": {
34
- "dev": "astro dev --host 0.0.0.0",
35
- "build": "pnpm build:ui && pnpm build:docs",
36
- "build:ui": "vite build && tsx scripts/post-build.ts",
37
- "build:docs": "astro build"
34
+ "build": "vite build && tsx scripts/post-build.ts"
38
35
  },
39
36
  "type": "module",
40
37
  "peerDependencies": {
@@ -1,3 +0,0 @@
1
- export { default as Container } from './Container.astro';
2
- export { default as Section } from './Section.astro';
3
- export { default as Main } from './Main.astro';