@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/dist/entities/MetaDoc.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { SidebarItemEntity } from './SidebarItem';
|
2
2
|
import type { MetaEntry } from '../database/MetaDB';
|
3
3
|
import { LinkUtil } from '../utils/link';
|
4
4
|
import { BaseDoc } from './BaseDoc';
|
@@ -44,12 +44,12 @@ export default class MetaDoc extends BaseDoc<typeof COLLECTION_NAME, MetaEntry>
|
|
44
44
|
/**
|
45
45
|
* 获取兄弟文档的侧边栏项目
|
46
46
|
*/
|
47
|
-
async getSiblingSidebarItems(): Promise<
|
47
|
+
async getSiblingSidebarItems(): Promise<SidebarItemEntity[]> {
|
48
48
|
const siblings = await this.getSiblingDocs();
|
49
49
|
const siblingItems = await Promise.all(
|
50
50
|
siblings.map((sibling) => {
|
51
|
-
return new
|
52
|
-
|
51
|
+
return new SidebarItemEntity({
|
52
|
+
text: sibling.getTitle(),
|
53
53
|
link: sibling.getLink(),
|
54
54
|
});
|
55
55
|
})
|
@@ -61,9 +61,9 @@ export default class MetaDoc extends BaseDoc<typeof COLLECTION_NAME, MetaEntry>
|
|
61
61
|
* 重写侧边栏项目方法
|
62
62
|
* 对于元数据页面,我们不显示子项目
|
63
63
|
*/
|
64
|
-
override async toSidebarItem(): Promise<
|
65
|
-
return new
|
66
|
-
|
64
|
+
override async toSidebarItem(): Promise<SidebarItemEntity> {
|
65
|
+
return new SidebarItemEntity({
|
66
|
+
text: this.getTitle(),
|
67
67
|
link: this.getLink(),
|
68
68
|
});
|
69
69
|
}
|
@@ -72,9 +72,9 @@ export default class MetaDoc extends BaseDoc<typeof COLLECTION_NAME, MetaEntry>
|
|
72
72
|
* 重写顶级侧边栏项目方法
|
73
73
|
* 对于元数据页面,我们显示所有兄弟页面作为侧边栏项目
|
74
74
|
*/
|
75
|
-
async getTopSidebarItem(): Promise<
|
76
|
-
return new
|
77
|
-
|
75
|
+
async getTopSidebarItem(): Promise<SidebarItemEntity> {
|
76
|
+
return new SidebarItemEntity({
|
77
|
+
text: '了解我们',
|
78
78
|
items: await this.getSiblingSidebarItems(),
|
79
79
|
link: '',
|
80
80
|
});
|
@@ -1,79 +1,75 @@
|
|
1
|
-
import { type
|
1
|
+
import { type ISidebarItem } from '../types/sidebar';
|
2
2
|
|
3
3
|
/**
|
4
4
|
* 侧边栏项目类
|
5
5
|
* 用于构建网站的侧边栏导航
|
6
6
|
*/
|
7
|
-
export class SidebarItemEntity implements
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
export class SidebarItemEntity implements ISidebarItem {
|
8
|
+
text: string;
|
9
|
+
href: string;
|
10
|
+
items: ISidebarItem[];
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
this.text = props.text;
|
18
|
-
this.href = props.link || '';
|
19
|
-
this.items = props.items || [];
|
20
|
-
}
|
12
|
+
constructor(props: { text: string; link?: string; items?: ISidebarItem[] }) {
|
13
|
+
this.text = props.text;
|
14
|
+
this.href = props.link || '';
|
15
|
+
this.items = props.items || [];
|
16
|
+
}
|
21
17
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
18
|
+
/**
|
19
|
+
* 添加子项目
|
20
|
+
* @param item 要添加的子项目
|
21
|
+
*/
|
22
|
+
addItem(item: SidebarItemEntity): void {
|
23
|
+
this.items.push(item);
|
24
|
+
}
|
29
25
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
26
|
+
/**
|
27
|
+
* 获取所有子项目
|
28
|
+
* @returns 子项目数组
|
29
|
+
*/
|
30
|
+
getItems(): SidebarItemEntity[] {
|
31
|
+
return this.items.map((item) => new SidebarItemEntity(item));
|
32
|
+
}
|
37
33
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
34
|
+
/**
|
35
|
+
* 获取项目标签
|
36
|
+
* @returns 项目标签
|
37
|
+
*/
|
38
|
+
getLabel(): string {
|
39
|
+
return this.text;
|
40
|
+
}
|
45
41
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
42
|
+
/**
|
43
|
+
* 获取项目链接
|
44
|
+
* @returns 项目链接
|
45
|
+
*/
|
46
|
+
getLink(): string {
|
47
|
+
return this.href;
|
48
|
+
}
|
53
49
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
50
|
+
/**
|
51
|
+
* 获取包括自身在内的所有项目
|
52
|
+
* @returns 包括自身在内的所有项目
|
53
|
+
*/
|
54
|
+
getItemsIncludingSelf(): SidebarItemEntity[] {
|
55
|
+
return [this, ...this.getItems()];
|
56
|
+
}
|
61
57
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
58
|
+
/**
|
59
|
+
* 判断是否是分组(有子项目)
|
60
|
+
* @returns 是否是分组
|
61
|
+
*/
|
62
|
+
isGroup(): boolean {
|
63
|
+
return this.items.length > 0;
|
64
|
+
}
|
69
65
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
66
|
+
/**
|
67
|
+
* 判断是否不是分组
|
68
|
+
* @returns 是否不是分组
|
69
|
+
*/
|
70
|
+
isNotGroup(): boolean {
|
71
|
+
return !this.isGroup();
|
72
|
+
}
|
77
73
|
}
|
78
74
|
|
79
75
|
/**
|
@@ -81,13 +77,13 @@ export class SidebarItemEntity implements SidebarItem {
|
|
81
77
|
* 实现此接口的类可以提供侧边栏项目
|
82
78
|
*/
|
83
79
|
export interface SidebarProvider {
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
80
|
+
/**
|
81
|
+
* 转换为侧边栏项目
|
82
|
+
*/
|
83
|
+
toSidebarItem(): Promise<SidebarItemEntity>;
|
88
84
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
}
|
85
|
+
/**
|
86
|
+
* 获取顶级侧边栏项目
|
87
|
+
*/
|
88
|
+
getTopSidebarItem?(): Promise<SidebarItemEntity>;
|
89
|
+
}
|
package/dist/entities/Tag.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import blogDB from '../database/BlogDB';
|
2
|
-
import {
|
3
|
-
import { type
|
2
|
+
import { SidebarItemEntity } from './SidebarItem';
|
3
|
+
import { type ITagStaticPath } from '../types/static-path';
|
4
4
|
import { LinkUtil } from '../utils/link';
|
5
5
|
|
6
6
|
export class Tag {
|
@@ -14,25 +14,25 @@ export class Tag {
|
|
14
14
|
this.lang = lang;
|
15
15
|
}
|
16
16
|
|
17
|
-
toSidebarItem(lang: string):
|
18
|
-
return new
|
19
|
-
|
17
|
+
toSidebarItem(lang: string): SidebarItemEntity {
|
18
|
+
return new SidebarItemEntity({
|
19
|
+
text: this.name,
|
20
20
|
link: LinkUtil.getTagLink(lang, this.name),
|
21
21
|
});
|
22
22
|
}
|
23
23
|
|
24
|
-
toTagPath():
|
24
|
+
toTagPath(): ITagStaticPath {
|
25
25
|
return {
|
26
26
|
params: { slug: this.lang + '/blogs/tag/' + this.name },
|
27
27
|
props: { tag: this.name },
|
28
28
|
};
|
29
29
|
}
|
30
30
|
|
31
|
-
static async makeRootSidebarItem(lang: string): Promise<
|
31
|
+
static async makeRootSidebarItem(lang: string): Promise<SidebarItemEntity> {
|
32
32
|
const tags = await blogDB.getTagsByLang(lang);
|
33
33
|
|
34
|
-
return new
|
35
|
-
|
34
|
+
return new SidebarItemEntity({
|
35
|
+
text: 'Tags',
|
36
36
|
link: LinkUtil.getTagLink(lang, ''),
|
37
37
|
items: tags.map((tag: Tag) => tag.toSidebarItem(lang)),
|
38
38
|
});
|
package/dist/index.ts
CHANGED
@@ -7,6 +7,14 @@ export { default as Alert } from './components/base/Alert.astro';
|
|
7
7
|
export { default as Speak } from './components/base/Speak.astro';
|
8
8
|
export { default as Module } from './components/base/Module.astro';
|
9
9
|
|
10
|
+
// Collections
|
11
|
+
export * from './collections/ArticleCollection';
|
12
|
+
export * from './collections/BlogCollection';
|
13
|
+
export * from './collections/CourseCollection';
|
14
|
+
export * from './collections/ExperimentCollection';
|
15
|
+
export * from './collections/LessonCollection';
|
16
|
+
export * from './collections/MetaCollection';
|
17
|
+
|
10
18
|
// Navigation
|
11
19
|
export { default as ThemeSwitcher } from './components/navigation/ThemeSwitcher.astro';
|
12
20
|
export { default as TableOfContents } from './components/navigation/TableOfContents.astro';
|
@@ -91,10 +99,22 @@ export * from './types/layout';
|
|
91
99
|
export * from './types/header';
|
92
100
|
export * from './types/heading';
|
93
101
|
export * from './types/meta';
|
102
|
+
export * from './types/nav';
|
103
|
+
export * from './types/product';
|
104
|
+
export * from './types/footer';
|
105
|
+
export * from './types/static-path';
|
94
106
|
export type { ImageProvider, ImageOptions } from './utils/image';
|
95
107
|
|
96
|
-
//
|
108
|
+
// Entities
|
97
109
|
export * from './entities/BaseDoc';
|
110
|
+
export * from './entities/BlogDoc';
|
111
|
+
export * from './entities/CourseDoc';
|
112
|
+
export * from './entities/ExperimentDoc';
|
113
|
+
export * from './entities/Heading';
|
114
|
+
export * from './entities/LessonDoc';
|
115
|
+
export * from './entities/MetaDoc';
|
116
|
+
export * from './entities/SidebarItem';
|
117
|
+
export * from './entities/Tag';
|
98
118
|
|
99
119
|
// Database
|
100
120
|
export * from './database/BaseDB';
|
package/dist/types/article.ts
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
export interface
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
export interface IArticleProps {
|
2
|
+
/**
|
3
|
+
* 文章的类名
|
4
|
+
*/
|
5
|
+
class?: string;
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
/**
|
8
|
+
* 类名列表
|
9
|
+
*/
|
10
|
+
'class:list'?: any;
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
/**
|
13
|
+
* 内联样式
|
14
|
+
*/
|
15
|
+
style?: string;
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
}
|
17
|
+
/**
|
18
|
+
* 文章宽度
|
19
|
+
* @default "medium"
|
20
|
+
*/
|
21
|
+
width?: 'narrow' | 'medium' | 'wide' | 'full';
|
22
|
+
}
|
package/dist/types/footer.ts
CHANGED
@@ -1,15 +1,6 @@
|
|
1
|
-
|
2
|
-
src: string;
|
3
|
-
alt: string;
|
4
|
-
}
|
5
|
-
|
6
|
-
export interface Product {
|
7
|
-
name: string;
|
8
|
-
href: string;
|
9
|
-
external?: boolean;
|
10
|
-
}
|
1
|
+
import type { ILogo, IProduct } from './product';
|
11
2
|
|
12
|
-
export interface
|
3
|
+
export interface IFooterProps {
|
13
4
|
/**
|
14
5
|
* 关于链接
|
15
6
|
*/
|
@@ -79,7 +70,7 @@ export interface FooterProps {
|
|
79
70
|
/**
|
80
71
|
* 徽标
|
81
72
|
*/
|
82
|
-
logo?:
|
73
|
+
logo?: ILogo;
|
83
74
|
|
84
75
|
/**
|
85
76
|
* 媒体链接
|
@@ -104,7 +95,7 @@ export interface FooterProps {
|
|
104
95
|
/**
|
105
96
|
* 产品
|
106
97
|
*/
|
107
|
-
products?:
|
98
|
+
products?: IProduct[];
|
108
99
|
|
109
100
|
/**
|
110
101
|
* 站点名称
|
package/dist/types/header.ts
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
import type { INavItem } from './nav';
|
2
|
+
|
3
|
+
export interface IHeaderProps {
|
2
4
|
/**
|
3
5
|
* 侧边栏是否默认展开
|
4
6
|
* @default false
|
@@ -30,7 +32,7 @@ export interface HeaderProps {
|
|
30
32
|
/**
|
31
33
|
* 导航菜单项
|
32
34
|
*/
|
33
|
-
navItems?:
|
35
|
+
navItems?: INavItem[];
|
34
36
|
|
35
37
|
/**
|
36
38
|
* 是否显示侧边栏切换按钮
|
@@ -60,5 +62,3 @@ export interface HeaderProps {
|
|
60
62
|
|
61
63
|
navPosition?: 'start' | 'center' | 'end';
|
62
64
|
}
|
63
|
-
|
64
|
-
export type NavItem = { href: string; label: string };
|
package/dist/types/heading.ts
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
/**
|
2
2
|
* 表示文档中的标题结构
|
3
3
|
*/
|
4
|
-
export interface
|
5
|
-
|
6
|
-
|
4
|
+
export interface IHeadingType {
|
5
|
+
/** 标题深度,如 h1=1, h2=2, h3=3 等 */
|
6
|
+
depth: number;
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
/** 标题的唯一标识符,用于锚点链接 */
|
9
|
+
slug: string;
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
}
|
11
|
+
/** 标题文本内容 */
|
12
|
+
text: string;
|
13
|
+
}
|
package/dist/types/layout.ts
CHANGED
@@ -1,71 +1,71 @@
|
|
1
|
-
import type {
|
2
|
-
import type {
|
3
|
-
import type {
|
4
|
-
import type {
|
5
|
-
import type {
|
1
|
+
import type { IFooterProps } from './footer';
|
2
|
+
import type { IHeaderProps } from './header';
|
3
|
+
import type { IMainContentProps } from './main';
|
4
|
+
import type { IMetaProps } from './meta';
|
5
|
+
import type { ISidebarProps } from './sidebar';
|
6
6
|
|
7
|
-
export interface
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
export interface IAppLayoutProps {
|
8
|
+
/**
|
9
|
+
* 是否显示侧边栏
|
10
|
+
* @default true
|
11
|
+
*/
|
12
|
+
showSidebar?: boolean;
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
/**
|
15
|
+
* 是否显示页眉
|
16
|
+
* @default true
|
17
|
+
*/
|
18
|
+
showHeader?: boolean;
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
/**
|
21
|
+
* 是否显示页脚
|
22
|
+
* @default true
|
23
|
+
*/
|
24
|
+
showFooter?: boolean;
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
/**
|
27
|
+
* 自定义头部内容
|
28
|
+
*/
|
29
|
+
head?: astroHTML.JSX.Element;
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
/**
|
32
|
+
* 自定义头部内容
|
33
|
+
*/
|
34
|
+
headerConfig: IHeaderProps;
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
/**
|
37
|
+
* 侧边栏配置
|
38
|
+
*/
|
39
|
+
sidebarConfig: ISidebarProps;
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
/**
|
42
|
+
* 主内容配置
|
43
|
+
*/
|
44
|
+
mainContentConfig: IMainContentProps;
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
/**
|
47
|
+
* 页面类名
|
48
|
+
*/
|
49
|
+
class?: string;
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
/**
|
52
|
+
* 类名列表
|
53
|
+
*/
|
54
|
+
'class:list'?: any;
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
56
|
+
/**
|
57
|
+
* 调试模式,显示各个部分的边框
|
58
|
+
* @default false
|
59
|
+
*/
|
60
|
+
debug?: boolean;
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
/**
|
63
|
+
* 元数据配置
|
64
|
+
*/
|
65
|
+
metaConfig: IMetaProps;
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
}
|
67
|
+
/**
|
68
|
+
* 页脚相关配置
|
69
|
+
*/
|
70
|
+
footerConfig: IFooterProps;
|
71
|
+
}
|