@coffic/cosy-ui 0.5.12 → 0.6.2
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.
- package/README.md +2 -31
- package/dist/collections/ArticleCollection.ts +19 -0
- package/dist/collections/BlogCollection.ts +28 -0
- package/dist/collections/CourseCollection.ts +11 -0
- package/dist/collections/ExperimentCollection.ts +18 -0
- package/dist/collections/LessonCollection.ts +25 -0
- package/dist/collections/MetaCollection.ts +17 -0
- package/dist/components/containers/Main.astro +2 -2
- package/dist/components/data-display/TeamMembers.astro +1 -1
- package/dist/components/display/Card.astro +0 -3
- package/dist/components/display/CodeBlock.astro +1 -2
- package/dist/components/display/Modal.astro +1 -2
- package/dist/components/icons/SearchIcon.astro +30 -34
- package/dist/components/icons/SunCloudyIcon.astro +35 -39
- package/dist/components/layouts/AppLayout.astro +2 -2
- package/dist/components/layouts/BaseLayout.astro +4 -3
- package/dist/components/layouts/Footer.astro +8 -14
- package/dist/components/layouts/Header.astro +6 -6
- package/dist/components/layouts/Sidebar.astro +2 -2
- package/dist/components/layouts/SidebarNav.astro +6 -6
- package/dist/components/navigation/TableOfContents.astro +6 -3
- package/dist/components/typography/Article.astro +2 -2
- package/dist/components/typography/Text.astro +1 -1
- package/dist/entities/MetaDoc.ts +10 -10
- package/dist/entities/SidebarItem.ts +68 -72
- package/dist/entities/Tag.ts +9 -9
- package/dist/index.ts +21 -1
- package/dist/types/article.ts +19 -19
- package/dist/types/footer.ts +4 -13
- package/dist/types/header.ts +4 -4
- package/dist/types/heading.ts +8 -8
- package/dist/types/layout.ts +59 -59
- package/dist/types/main.ts +68 -57
- package/dist/types/meta.ts +49 -49
- package/dist/types/nav.ts +1 -0
- package/dist/types/product.ts +10 -0
- package/dist/types/sidebar.ts +29 -26
- package/dist/types/static-path.ts +1 -1
- package/dist/utils/lang_package.ts +205 -206
- package/package.json +3 -3
package/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[](README.md)
|
4
4
|
[](README-zh.md)
|
5
|
+
[](README-dev.md)
|
5
6
|
[](https://www.npmjs.com/package/@coffic/cosy-ui)
|
6
7
|
[](https://coffic.cn)
|
7
8
|
[](https://github.com/nookery)
|
@@ -23,34 +24,4 @@ Usage in Astro components:
|
|
23
24
|
import { Button } from "@coffic/cosy-ui";
|
24
25
|
---
|
25
26
|
<Button>Hi</Button>
|
26
|
-
```
|
27
|
-
|
28
|
-
## Development
|
29
|
-
|
30
|
-
### Install Dependencies
|
31
|
-
|
32
|
-
```bash
|
33
|
-
pnpm install
|
34
|
-
```
|
35
|
-
|
36
|
-
### Start Development Server
|
37
|
-
|
38
|
-
```bash
|
39
|
-
pnpm dev
|
40
|
-
```
|
41
|
-
|
42
|
-
### Build
|
43
|
-
|
44
|
-
Build:
|
45
|
-
|
46
|
-
```bash
|
47
|
-
pnpm build
|
48
|
-
```
|
49
|
-
|
50
|
-
## Contributing
|
51
|
-
|
52
|
-
Issues and Pull Requests are welcome!
|
53
|
-
|
54
|
-
## License
|
55
|
-
|
56
|
-
MIT
|
27
|
+
```
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { defineCollection, z } from 'astro:content';
|
2
|
+
import { glob } from 'astro/loaders';
|
3
|
+
|
4
|
+
export const makeArticleCollection = (base: string) => {
|
5
|
+
return defineCollection({
|
6
|
+
loader: glob({
|
7
|
+
pattern: '**/*.{md,mdx}',
|
8
|
+
base,
|
9
|
+
}),
|
10
|
+
schema: articleSchema,
|
11
|
+
});
|
12
|
+
};
|
13
|
+
|
14
|
+
export const articleSchema = z.object({
|
15
|
+
title: z.string(),
|
16
|
+
folder: z.boolean(),
|
17
|
+
order: z.number(),
|
18
|
+
description: z.string().optional(),
|
19
|
+
});
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { defineCollection, z } from 'astro:content';
|
2
|
+
import { glob } from 'astro/loaders';
|
3
|
+
|
4
|
+
export const blogSchema = z.object({
|
5
|
+
title: z.string(),
|
6
|
+
description: z.string().optional(),
|
7
|
+
tags: z.array(z.string()).optional(),
|
8
|
+
date: z.date().optional(),
|
9
|
+
authors: z
|
10
|
+
.array(
|
11
|
+
z.object({
|
12
|
+
name: z.string(),
|
13
|
+
picture: z.string().optional(),
|
14
|
+
url: z.string().optional(),
|
15
|
+
})
|
16
|
+
)
|
17
|
+
.optional(),
|
18
|
+
});
|
19
|
+
|
20
|
+
export const makeBlogCollection = (base: string) => {
|
21
|
+
return defineCollection({
|
22
|
+
loader: glob({
|
23
|
+
pattern: '**/*.{md,mdx}',
|
24
|
+
base,
|
25
|
+
}),
|
26
|
+
schema: blogSchema,
|
27
|
+
});
|
28
|
+
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { defineCollection, z } from 'astro:content';
|
2
|
+
import { glob } from 'astro/loaders';
|
3
|
+
|
4
|
+
export const experimentSchema = z.object({
|
5
|
+
title: z.string(),
|
6
|
+
description: z.string().optional(),
|
7
|
+
pubDate: z.date().optional(),
|
8
|
+
});
|
9
|
+
|
10
|
+
export const makeExperimentCollection = (base: string) => {
|
11
|
+
return defineCollection({
|
12
|
+
loader: glob({
|
13
|
+
pattern: '**/*.{md,mdx}',
|
14
|
+
base,
|
15
|
+
}),
|
16
|
+
schema: experimentSchema,
|
17
|
+
});
|
18
|
+
};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { defineCollection, z } from 'astro:content';
|
2
|
+
import { glob } from 'astro/loaders';
|
3
|
+
|
4
|
+
export const lessonSchema = z.object({
|
5
|
+
title: z.string(),
|
6
|
+
description: z.string().optional(),
|
7
|
+
authors: z
|
8
|
+
.array(
|
9
|
+
z.object({
|
10
|
+
name: z.string(),
|
11
|
+
picture: z.string().optional(),
|
12
|
+
})
|
13
|
+
)
|
14
|
+
.optional(),
|
15
|
+
});
|
16
|
+
|
17
|
+
export const makeLessonCollection = (base: string) => {
|
18
|
+
return defineCollection({
|
19
|
+
loader: glob({
|
20
|
+
pattern: '**/*.{md,mdx}',
|
21
|
+
base,
|
22
|
+
}),
|
23
|
+
schema: lessonSchema,
|
24
|
+
});
|
25
|
+
};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { defineCollection, z } from 'astro:content';
|
2
|
+
import { glob } from 'astro/loaders';
|
3
|
+
|
4
|
+
export const metaSchema = z.object({
|
5
|
+
title: z.string(),
|
6
|
+
description: z.string().optional(),
|
7
|
+
});
|
8
|
+
|
9
|
+
export const makeMetaCollection = (base: string) => {
|
10
|
+
return defineCollection({
|
11
|
+
loader: glob({
|
12
|
+
pattern: '**/*.{md,mdx}',
|
13
|
+
base,
|
14
|
+
}),
|
15
|
+
schema: metaSchema,
|
16
|
+
});
|
17
|
+
};
|
@@ -48,11 +48,11 @@
|
|
48
48
|
* ```
|
49
49
|
*/
|
50
50
|
import '../../app.css';
|
51
|
-
import type {
|
51
|
+
import type { IMainContentProps } from '../../index';
|
52
52
|
import Article from '../typography/Article.astro';
|
53
53
|
import TableOfContents from '../navigation/TableOfContents.astro';
|
54
54
|
|
55
|
-
export interface Props extends
|
55
|
+
export interface Props extends IMainContentProps {}
|
56
56
|
|
57
57
|
const {
|
58
58
|
size = 'md',
|
@@ -93,7 +93,7 @@ const getGridClasses = (cols: 2 | 3 | 4) => {
|
|
93
93
|
<div class:list={['cosy:w-full cosy:mx-auto cosy:px-4', className]}>
|
94
94
|
<div class:list={['cosy:grid cosy:gap-6', ...getGridClasses(columnsValue)]}>
|
95
95
|
{
|
96
|
-
members.map((member: TeamMemberData
|
96
|
+
members.map((member: TeamMemberData) => (
|
97
97
|
<div class="cosy:transition-all cosy:hover:-translate-y-1 cosy:duration-300 cosy:transform">
|
98
98
|
<TeamMember {...member} />
|
99
99
|
</div>
|
@@ -51,12 +51,11 @@ import '../../app.css';
|
|
51
51
|
|
52
52
|
interface Props {
|
53
53
|
code: string;
|
54
|
-
lang?: string;
|
55
54
|
title?: string;
|
56
55
|
showLineNumbers?: boolean;
|
57
56
|
}
|
58
57
|
|
59
|
-
const { code,
|
58
|
+
const { code, title, showLineNumbers = true } = Astro.props;
|
60
59
|
|
61
60
|
// 移除代码字符串开头和结尾的空行
|
62
61
|
const trimmedCode = code.trim();
|
@@ -103,7 +103,7 @@ const { id, title, showCloseButton = true, class: className = '' } = Astro.props
|
|
103
103
|
</form>
|
104
104
|
</dialog>
|
105
105
|
|
106
|
-
<script define:vars={{ id }}>
|
106
|
+
<script is:inline define:vars={{ id }}>
|
107
107
|
// 为了方便使用,我们提供一些辅助方法
|
108
108
|
document.addEventListener('DOMContentLoaded', () => {
|
109
109
|
const modal = document.getElementById(id);
|
@@ -117,4 +117,3 @@ const { id, title, showCloseButton = true, class: className = '' } = Astro.props
|
|
117
117
|
});
|
118
118
|
});
|
119
119
|
</script>
|
120
|
-
|
@@ -1,40 +1,36 @@
|
|
1
1
|
---
|
2
2
|
interface Props {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
/**
|
18
|
-
* 插槽名称
|
19
|
-
*/
|
20
|
-
slot?: string;
|
3
|
+
/**
|
4
|
+
* 图标的大小
|
5
|
+
* @default "24px"
|
6
|
+
*/
|
7
|
+
size?: string;
|
8
|
+
/**
|
9
|
+
* 图标的颜色
|
10
|
+
* @default "currentColor"
|
11
|
+
*/
|
12
|
+
color?: string;
|
13
|
+
/**
|
14
|
+
* 自定义类名
|
15
|
+
*/
|
16
|
+
class?: string;
|
21
17
|
}
|
22
18
|
|
23
|
-
const { size = '24px', color = 'currentColor', class: className = ''
|
19
|
+
const { size = '24px', color = 'currentColor', class: className = '' } = Astro.props;
|
24
20
|
---
|
25
21
|
|
26
|
-
<svg
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
>
|
38
|
-
|
39
|
-
|
40
|
-
|
22
|
+
<svg
|
23
|
+
xmlns="http://www.w3.org/2000/svg"
|
24
|
+
width={size}
|
25
|
+
height={size}
|
26
|
+
viewBox="0 0 24 24"
|
27
|
+
fill="none"
|
28
|
+
stroke={color}
|
29
|
+
stroke-width="2"
|
30
|
+
stroke-linecap="round"
|
31
|
+
stroke-linejoin="round"
|
32
|
+
class={className}>
|
33
|
+
<circle cx="11" cy="11" r="8"></circle>
|
34
|
+
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
|
35
|
+
</svg>
|
36
|
+
|
@@ -1,45 +1,41 @@
|
|
1
1
|
---
|
2
2
|
interface Props {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
/**
|
18
|
-
* 插槽名称
|
19
|
-
*/
|
20
|
-
slot?: string;
|
3
|
+
/**
|
4
|
+
* 图标的大小
|
5
|
+
* @default "24px"
|
6
|
+
*/
|
7
|
+
size?: string;
|
8
|
+
/**
|
9
|
+
* 图标的颜色
|
10
|
+
* @default "currentColor"
|
11
|
+
*/
|
12
|
+
color?: string;
|
13
|
+
/**
|
14
|
+
* 自定义类名
|
15
|
+
*/
|
16
|
+
class?: string;
|
21
17
|
}
|
22
18
|
|
23
|
-
const { size = '24px', color = 'currentColor', class: className = ''
|
19
|
+
const { size = '24px', color = 'currentColor', class: className = '' } = Astro.props;
|
24
20
|
---
|
25
21
|
|
26
|
-
<svg
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
>
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
22
|
+
<svg
|
23
|
+
xmlns="http://www.w3.org/2000/svg"
|
24
|
+
width={size}
|
25
|
+
height={size}
|
26
|
+
viewBox="0 0 24 24"
|
27
|
+
fill="none"
|
28
|
+
stroke={color}
|
29
|
+
stroke-width="2"
|
30
|
+
stroke-linecap="round"
|
31
|
+
stroke-linejoin="round"
|
32
|
+
class={className}>
|
33
|
+
<path d="M12 2v2"></path>
|
34
|
+
<path d="M2 12h2"></path>
|
35
|
+
<path d="M20 12h2"></path>
|
36
|
+
<path d="M4.93 4.93l1.41 1.41"></path>
|
37
|
+
<path d="M17.66 4.93l-1.41 1.41"></path>
|
38
|
+
<path d="M12 19a4 4 0 100-8 4 4 0 000 8z"></path>
|
39
|
+
<path d="M12 15a7 7 0 00-7 7h14a7 7 0 00-7-7z"></path>
|
40
|
+
</svg>
|
41
|
+
|
@@ -172,10 +172,10 @@ import Main from '../containers/Main.astro';
|
|
172
172
|
import Header from './Header.astro';
|
173
173
|
import Sidebar from './Sidebar.astro';
|
174
174
|
import { ClientRouter } from 'astro:transitions';
|
175
|
-
import type {
|
175
|
+
import type { IAppLayoutProps } from '../../index';
|
176
176
|
import Container from '../containers/Container.astro';
|
177
177
|
|
178
|
-
interface Props extends
|
178
|
+
interface Props extends IAppLayoutProps {}
|
179
179
|
|
180
180
|
const {
|
181
181
|
sidebarConfig,
|
@@ -50,9 +50,9 @@
|
|
50
50
|
*/
|
51
51
|
|
52
52
|
import '../../app.css';
|
53
|
-
import type
|
53
|
+
import { LinkUtil, type IMetaProps } from '../../index';
|
54
54
|
|
55
|
-
export interface Props extends
|
55
|
+
export interface Props extends IMetaProps {
|
56
56
|
debug?: boolean;
|
57
57
|
}
|
58
58
|
|
@@ -71,6 +71,7 @@ const {
|
|
71
71
|
|
72
72
|
// 处理类名
|
73
73
|
let bodyClasses = debug ? 'cosy:border cosy:border-red-500' : className || '';
|
74
|
+
const faviconPath = LinkUtil.createUrl('/favicon.png');
|
74
75
|
---
|
75
76
|
|
76
77
|
<!doctype html>
|
@@ -82,7 +83,7 @@ let bodyClasses = debug ? 'cosy:border cosy:border-red-500' : className || '';
|
|
82
83
|
{description && <meta name="description" content={description} />}
|
83
84
|
{keywords && <meta name="keywords" content={keywords} />}
|
84
85
|
<meta name="generator" content={Astro.generator} />
|
85
|
-
<link rel="icon" type="image/svg+xml" href=
|
86
|
+
<link rel="icon" type="image/svg+xml" href={faviconPath} />
|
86
87
|
|
87
88
|
<!-- 自定义样式 -->
|
88
89
|
{customStyles && <style set:html={customStyles} />}
|
@@ -147,7 +147,7 @@
|
|
147
147
|
|
148
148
|
import { processSocialLink } from '../../utils/social';
|
149
149
|
import SocialIcon from '../icons/SocialIcon.astro';
|
150
|
-
import type {
|
150
|
+
import type { IFooterProps } from '../../types/footer';
|
151
151
|
import { createTextGetter } from '../../utils/i18n';
|
152
152
|
import NavSection from './NavSection.astro';
|
153
153
|
import { LanguageUtil } from '../../utils/language';
|
@@ -178,7 +178,7 @@ const {
|
|
178
178
|
mediaLink,
|
179
179
|
techStackLink,
|
180
180
|
debug = false,
|
181
|
-
} = Astro.props as
|
181
|
+
} = Astro.props as IFooterProps;
|
182
182
|
|
183
183
|
// 获取当前语言
|
184
184
|
const lang = LanguageUtil.getCurrentLanguage(Astro);
|
@@ -210,14 +210,12 @@ const debugClasses = debug
|
|
210
210
|
class:list={[
|
211
211
|
'cosy:footer cosy:z-50 cosy:sm:footer-horizontal cosy:bg-base-200 cosy:text-base-content cosy:p-10',
|
212
212
|
debugClasses.footer,
|
213
|
-
]}
|
214
|
-
>
|
213
|
+
]}>
|
215
214
|
<div
|
216
215
|
class:list={[
|
217
216
|
'cosy:flex cosy:flex-col cosy:md:h-56 cosy:gap-8 cosy:container cosy:mx-auto cosy:items-center cosy:w-full cosy:md:flex-row cosy:md:justify-between',
|
218
217
|
debugClasses.section,
|
219
|
-
]}
|
220
|
-
>
|
218
|
+
]}>
|
221
219
|
{/* 品牌区域 */}
|
222
220
|
<aside class:list={['cosy:max-w-xs cosy:text-center', debugClasses.aside]}>
|
223
221
|
<a href={homeLink} class="cosy:flex cosy:items-center cosy:gap-2 cosy:mb-4 cosy:no-underline">
|
@@ -248,8 +246,7 @@ const debugClasses = debug
|
|
248
246
|
class="cosy:btn cosy:btn-circle cosy:btn-ghost cosy:btn-sm"
|
249
247
|
target="_blank"
|
250
248
|
rel="noopener noreferrer"
|
251
|
-
aria-label={link.name}
|
252
|
-
>
|
249
|
+
aria-label={link.name}>
|
253
250
|
<SocialIcon platform={link.platform} />
|
254
251
|
</a>
|
255
252
|
))}
|
@@ -263,8 +260,7 @@ const debugClasses = debug
|
|
263
260
|
class:list={[
|
264
261
|
'cosy:flex cosy:h-full cosy:flex-col cosy:justify-center cosy:gap-8 cosy:mx-auto cosy:max-w-xl cosy:text-center cosy:items-center cosy:w-full cosy:md:flex-row cosy:md:justify-between cosy:md:items-start',
|
265
262
|
debugClasses.section,
|
266
|
-
]}
|
267
|
-
>
|
263
|
+
]}>
|
268
264
|
{/* 产品导航 */}
|
269
265
|
{products.length > 0 && <NavSection title={t('products')} links={products} />}
|
270
266
|
|
@@ -328,8 +324,7 @@ const debugClasses = debug
|
|
328
324
|
class:list={[
|
329
325
|
'cosy:p-4 cosy:bg-primary cosy:text-primary-content cosy:w-full',
|
330
326
|
debugClasses.aside,
|
331
|
-
]}
|
332
|
-
>
|
327
|
+
]}>
|
333
328
|
<p class="cosy:text-center">{inspirationalSlogan}</p>
|
334
329
|
</aside>
|
335
330
|
)
|
@@ -340,8 +335,7 @@ const debugClasses = debug
|
|
340
335
|
class:list={[
|
341
336
|
'cosy:footer cosy:footer-center cosy:p-4 cosy:bg-base-300 cosy:text-base-content',
|
342
337
|
debugClasses.footer,
|
343
|
-
]}
|
344
|
-
>
|
338
|
+
]}>
|
345
339
|
<aside class:list={['cosy:items-center cosy:grid-flow-col', debugClasses.aside]}>
|
346
340
|
<p class="cosy:opacity-70 cosy:text-sm">
|
347
341
|
© {currentYear}
|
@@ -60,10 +60,10 @@
|
|
60
60
|
import '../../app.css';
|
61
61
|
import Link from '../base/Link.astro';
|
62
62
|
import Image from '../base/Image.astro';
|
63
|
-
import { LanguageSwitcher, LinkUtil, type
|
63
|
+
import { LanguageSwitcher, LinkUtil, type IHeaderProps, type INavItem } from '../../index';
|
64
64
|
import Logo from '../../assets/logo-rounded.png';
|
65
65
|
|
66
|
-
export interface Props extends
|
66
|
+
export interface Props extends IHeaderProps {
|
67
67
|
debug?: boolean;
|
68
68
|
}
|
69
69
|
|
@@ -119,7 +119,7 @@ const linkHeightClass = linkHeightClasses[height];
|
|
119
119
|
const currentPath = Astro.url.pathname;
|
120
120
|
const activeLink = LinkUtil.getActiveLink(
|
121
121
|
currentPath,
|
122
|
-
navItems.map((item:
|
122
|
+
navItems.map((item: INavItem) => item.href)
|
123
123
|
);
|
124
124
|
---
|
125
125
|
|
@@ -187,7 +187,7 @@ const activeLink = LinkUtil.getActiveLink(
|
|
187
187
|
'cosy:hidden cosy:lg:flex cosy:px-1 cosy:menu cosy:menu-horizontal',
|
188
188
|
linkHeightClass,
|
189
189
|
]}>
|
190
|
-
{navItems.map((item:
|
190
|
+
{navItems.map((item: INavItem) => (
|
191
191
|
<li>
|
192
192
|
<Link
|
193
193
|
variant={activeLink == item.href ? 'primary' : 'default'}
|
@@ -224,7 +224,7 @@ const activeLink = LinkUtil.getActiveLink(
|
|
224
224
|
navPosition === 'center' && (
|
225
225
|
<div class="cosy:hidden cosy:lg:flex cosy:navbar-center">
|
226
226
|
<ul class:list={['cosy:px-1 cosy:menu cosy:menu-horizontal', linkHeightClass]}>
|
227
|
-
{navItems.map((item:
|
227
|
+
{navItems.map((item: INavItem) => (
|
228
228
|
<li>
|
229
229
|
<Link
|
230
230
|
variant={activeLink == item.href ? 'primary' : 'default'}
|
@@ -248,7 +248,7 @@ const activeLink = LinkUtil.getActiveLink(
|
|
248
248
|
'cosy:hidden cosy:lg:flex cosy:px-1 cosy:menu cosy:menu-horizontal',
|
249
249
|
linkHeightClass,
|
250
250
|
]}>
|
251
|
-
{navItems.map((item:
|
251
|
+
{navItems.map((item: INavItem) => (
|
252
252
|
<li>
|
253
253
|
<Link
|
254
254
|
variant={activeLink == item.href ? 'primary' : 'default'}
|
@@ -26,9 +26,9 @@ import { isPathMatch } from '../../utils/path';
|
|
26
26
|
import Modal from '../display/Modal.astro';
|
27
27
|
import SidebarNav from './SidebarNav.astro';
|
28
28
|
import MenuIcon from '../icons/MenuIcon.astro';
|
29
|
-
import type {
|
29
|
+
import type { ISidebarProps } from '../../index';
|
30
30
|
|
31
|
-
export interface Props extends
|
31
|
+
export interface Props extends ISidebarProps {}
|
32
32
|
|
33
33
|
const {
|
34
34
|
sidebarItems,
|
@@ -7,13 +7,13 @@
|
|
7
7
|
|
8
8
|
import { isPathMatch } from '../../utils/path';
|
9
9
|
import '../../app.css';
|
10
|
-
import type {
|
10
|
+
import type { ISidebarItem } from '../../types/sidebar';
|
11
11
|
|
12
12
|
interface Props {
|
13
13
|
/**
|
14
14
|
* 侧边栏项目
|
15
15
|
*/
|
16
|
-
sidebarItems:
|
16
|
+
sidebarItems: ISidebarItem[];
|
17
17
|
|
18
18
|
/**
|
19
19
|
* 当前路径
|
@@ -39,13 +39,13 @@ const debugClass = debug ? 'cosy:border cosy:border-red-500' : '';
|
|
39
39
|
|
40
40
|
<nav class:list={['cosy:p-4', debugClass, className]}>
|
41
41
|
{
|
42
|
-
sidebarItems.map((section:
|
42
|
+
sidebarItems.map((section: ISidebarItem) => (
|
43
43
|
<div class:list={['cosy:mb-6', debugClass]}>
|
44
44
|
<h3 class:list={['cosy:font-bold cosy:mb-2 cosy:text-base-content/70', debugClass]}>
|
45
45
|
{section.text}
|
46
46
|
</h3>
|
47
47
|
<ul class:list={['cosy:menu cosy:bg-base-200 cosy:rounded-box cosy:w-56', debugClass]}>
|
48
|
-
{section.items?.map((item:
|
48
|
+
{section.items?.map((item: ISidebarItem) => {
|
49
49
|
const isActive = isPathMatch(currentPath, item.href);
|
50
50
|
return (
|
51
51
|
<li class:list={[debugClass]}>
|
@@ -60,7 +60,7 @@ const debugClass = debug ? 'cosy:border cosy:border-red-500' : '';
|
|
60
60
|
</a>
|
61
61
|
{item.items && (
|
62
62
|
<ul class:list={[debugClass]}>
|
63
|
-
{item.items.map((subitem:
|
63
|
+
{item.items.map((subitem: ISidebarItem) => {
|
64
64
|
const isSubActive = isPathMatch(currentPath, subitem.href);
|
65
65
|
return (
|
66
66
|
<li class:list={[debugClass]}>
|
@@ -75,7 +75,7 @@ const debugClass = debug ? 'cosy:border cosy:border-red-500' : '';
|
|
75
75
|
</a>
|
76
76
|
{subitem.items && (
|
77
77
|
<ul class:list={[debugClass]}>
|
78
|
-
{subitem.items.map((subsubitem:
|
78
|
+
{subitem.items.map((subsubitem: ISidebarItem) => {
|
79
79
|
const isSubSubActive = isPathMatch(currentPath, subsubitem.href);
|
80
80
|
return (
|
81
81
|
<li class:list={[debugClass]}>
|
@@ -125,8 +125,7 @@ const tocId = `toc-${Math.random().toString(36).substring(2, 9)}`;
|
|
125
125
|
<div
|
126
126
|
class={`toc-container toc-scroll-container ${fixed ? 'cosy:w-64' : 'cosy:w-full cosy:max-w-xs'}`}
|
127
127
|
id={`${tocId}-container`}
|
128
|
-
style="display: none;"
|
129
|
-
>
|
128
|
+
style="display: none;">
|
130
129
|
<div class="cosy:bg-base-100 cosy:shadow-inner cosy:card">
|
131
130
|
<div class="cosy:p-4 cosy:card-body">
|
132
131
|
<div class="cosy:mb-2 cosy:font-bold cosy:text-lg cosy:card-title">{titleText}</div>
|
@@ -140,7 +139,11 @@ const tocId = `toc-${Math.random().toString(36).substring(2, 9)}`;
|
|
140
139
|
</div>
|
141
140
|
</aside>
|
142
141
|
|
143
|
-
<script
|
142
|
+
<script
|
143
|
+
is:inline
|
144
|
+
define:vars={{ selector, maxDepth, tocId, containerSelector, minHeadings, langInfo }}
|
145
|
+
>
|
146
|
+
// @ts-nocheck
|
144
147
|
// 在页面加载完成后生成目录
|
145
148
|
function generateTOC() {
|
146
149
|
// 使用指定的容器选择器查找内容容器
|
@@ -105,9 +105,9 @@
|
|
105
105
|
|
106
106
|
// 导入样式
|
107
107
|
import '../../app.css';
|
108
|
-
import type {
|
108
|
+
import type { IArticleProps } from '@/types/article';
|
109
109
|
|
110
|
-
export interface Props extends
|
110
|
+
export interface Props extends IArticleProps {}
|
111
111
|
|
112
112
|
const { class: className = '', width = 'medium', style = '' } = Astro.props;
|
113
113
|
|