@jet-w/astro-blog 0.2.2 → 0.2.3

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,142 @@
1
+ /**
2
+ * 侧边栏配置系统
3
+ *
4
+ * 支持三种配置类型:
5
+ * 1. scan - 扫描指定文件夹,自动生成树形结构
6
+ * 2. manual - 手动配置显示特定内容
7
+ * 3. mixed - 混合使用以上两种方式
8
+ */
9
+
10
+ // 路径匹配配置
11
+ export interface PathMatchConfig {
12
+ pattern: string;
13
+ exact?: boolean;
14
+ }
15
+
16
+ // 侧边栏项目类型
17
+ export interface SidebarItem {
18
+ title: string;
19
+ slug?: string;
20
+ link?: string;
21
+ icon?: string;
22
+ badge?: string;
23
+ badgeType?: 'info' | 'success' | 'warning' | 'error';
24
+ children?: SidebarItem[];
25
+ collapsed?: boolean;
26
+ }
27
+
28
+ // 扫描配置
29
+ export interface ScanConfig {
30
+ type: 'scan';
31
+ title: string;
32
+ icon?: string;
33
+ scanPath: string;
34
+ collapsed?: boolean;
35
+ maxDepth?: number;
36
+ exclude?: string[];
37
+ include?: string[];
38
+ sortBy?: 'name' | 'date' | 'title' | 'custom';
39
+ sortOrder?: 'asc' | 'desc';
40
+ showForPaths?: string[];
41
+ hideForPaths?: string[];
42
+ }
43
+
44
+ // 手动配置
45
+ export interface ManualConfig {
46
+ type: 'manual';
47
+ title: string;
48
+ icon?: string;
49
+ collapsed?: boolean;
50
+ items: SidebarItem[];
51
+ showForPaths?: string[];
52
+ hideForPaths?: string[];
53
+ }
54
+
55
+ // 混合配置
56
+ export interface MixedConfig {
57
+ type: 'mixed';
58
+ title: string;
59
+ icon?: string;
60
+ collapsed?: boolean;
61
+ sections: (ScanConfig | ManualConfig)[];
62
+ showForPaths?: string[];
63
+ hideForPaths?: string[];
64
+ }
65
+
66
+ // 分隔符
67
+ export interface DividerConfig {
68
+ type: 'divider';
69
+ title?: string;
70
+ showForPaths?: string[];
71
+ hideForPaths?: string[];
72
+ }
73
+
74
+ // 侧边栏组配置
75
+ export type SidebarGroup = ScanConfig | ManualConfig | MixedConfig | DividerConfig;
76
+
77
+ // 完整侧边栏配置
78
+ export interface SidebarConfig {
79
+ enabled: boolean;
80
+ width?: string;
81
+ position?: 'left' | 'right';
82
+ showSearch?: boolean;
83
+ showRecentPosts?: boolean;
84
+ recentPostsCount?: number;
85
+ showPopularTags?: boolean;
86
+ popularTagsCount?: number;
87
+ showArchives?: boolean;
88
+ archivesCount?: number;
89
+ showFriendLinks?: boolean;
90
+ friendLinks?: Array<{
91
+ title: string;
92
+ url: string;
93
+ icon?: string;
94
+ description?: string;
95
+ }>;
96
+ groups: SidebarGroup[];
97
+ }
98
+
99
+ /**
100
+ * 默认侧边栏配置
101
+ */
102
+ export const sidebarConfig: SidebarConfig = {
103
+ enabled: true,
104
+ width: '280px',
105
+ position: 'right',
106
+ showSearch: true,
107
+ showRecentPosts: true,
108
+ recentPostsCount: 5,
109
+ showPopularTags: true,
110
+ popularTagsCount: 8,
111
+ showArchives: true,
112
+ archivesCount: 6,
113
+ showFriendLinks: true,
114
+ friendLinks: [
115
+ { title: 'Astro 官网', url: 'https://astro.build' },
116
+ { title: 'Tailwind CSS', url: 'https://tailwindcss.com' },
117
+ { title: 'Vue.js', url: 'https://vuejs.org' },
118
+ ],
119
+ groups: [
120
+ {
121
+ type: 'scan',
122
+ title: '文档目录',
123
+ icon: 'folder',
124
+ scanPath: '',
125
+ collapsed: false,
126
+ }
127
+ ]
128
+ };
129
+
130
+ /**
131
+ * Define sidebar configuration
132
+ */
133
+ export function defineSidebarConfig(config: Partial<SidebarConfig>): SidebarConfig {
134
+ return {
135
+ ...sidebarConfig,
136
+ ...config,
137
+ groups: config.groups || sidebarConfig.groups
138
+ };
139
+ }
140
+
141
+ // 向后兼容
142
+ export const defaultSidebarConfig = sidebarConfig;
@@ -0,0 +1,61 @@
1
+ import type { SiteConfig } from '../types';
2
+
3
+ /**
4
+ * Default site configuration
5
+ * Users should override this in their own config
6
+ */
7
+ export const siteConfig: SiteConfig = {
8
+ title: 'My Astro Blog',
9
+ description: '',
10
+ author: 'Author',
11
+ email: '',
12
+ avatar: '/images/avatar.svg',
13
+ social: {
14
+ github: '',
15
+ twitter: '',
16
+ linkedin: '',
17
+ email: ''
18
+ },
19
+ menu: [
20
+ {
21
+ name: '首页',
22
+ href: '/',
23
+ icon: 'home'
24
+ },
25
+ {
26
+ name: '博客',
27
+ href: '/posts',
28
+ icon: 'posts'
29
+ },
30
+ {
31
+ name: '关于',
32
+ href: '/about',
33
+ icon: 'about'
34
+ }
35
+ ]
36
+ };
37
+
38
+ export const defaultSEO = {
39
+ title: siteConfig.title,
40
+ description: siteConfig.description,
41
+ image: '/images/og-image.jpg',
42
+ type: 'website' as const
43
+ };
44
+
45
+ /**
46
+ * Create site config with user overrides
47
+ */
48
+ export function defineSiteConfig(config: Partial<SiteConfig>): SiteConfig {
49
+ return {
50
+ ...siteConfig,
51
+ ...config,
52
+ social: {
53
+ ...siteConfig.social,
54
+ ...config.social
55
+ },
56
+ menu: config.menu || siteConfig.menu
57
+ };
58
+ }
59
+
60
+ // 向后兼容的别名
61
+ export const defaultSiteConfig = siteConfig;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * 社交链接配置
3
+ */
4
+
5
+ export interface SocialLink {
6
+ type: string;
7
+ url: string;
8
+ label?: string;
9
+ icon?: string;
10
+ }
11
+
12
+ export const defaultIcons: Record<string, string> = {
13
+ github: 'M12 0C5.374 0 0 5.373 0 12c0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23A11.509 11.509 0 0112 5.803c1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576C20.566 21.797 24 17.3 24 12c0-6.627-5.373-12-12-12z',
14
+ twitter: 'M23.953 4.57a10 10 0 01-2.825.775 4.958 4.958 0 002.163-2.723c-.951.555-2.005.959-3.127 1.184a4.92 4.92 0 00-8.384 4.482C7.69 8.095 4.067 6.13 1.64 3.162a4.822 4.822 0 00-.666 2.475c0 1.71.87 3.213 2.188 4.096a4.904 4.904 0 01-2.228-.616v.06a4.923 4.923 0 003.946 4.827 4.996 4.996 0 01-2.212.085 4.936 4.936 0 004.604 3.417 9.867 9.867 0 01-6.102 2.105c-.39 0-.779-.023-1.17-.067a13.995 13.995 0 007.557 2.209c9.053 0 13.998-7.496 13.998-13.985 0-.21 0-.42-.015-.63A9.935 9.935 0 0024 4.59z',
15
+ linkedin: 'M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z',
16
+ email: 'M3 8l7.89 4.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z',
17
+ youtube: 'M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z',
18
+ discord: 'M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189z'
19
+ };
20
+
21
+ export const socialLinks: SocialLink[] = [];
22
+ export const defaultSocialLinks = socialLinks;
23
+
24
+ /**
25
+ * Define social links
26
+ */
27
+ export function defineSocialLinks(links: SocialLink[]): SocialLink[] {
28
+ return links;
29
+ }
@@ -0,0 +1,80 @@
1
+ export interface BlogPost {
2
+ slug: string;
3
+ title: string;
4
+ description: string;
5
+ content: string;
6
+ pubDate: Date;
7
+ updatedDate?: Date;
8
+ tags: string[];
9
+ categories: string[];
10
+ author?: string;
11
+ image?: string;
12
+ draft?: boolean;
13
+ readingTime?: number;
14
+ }
15
+
16
+ export interface PostFrontmatter {
17
+ title: string;
18
+ description: string;
19
+ pubDate: string;
20
+ updatedDate?: string;
21
+ tags?: string[];
22
+ categories?: string[];
23
+ author?: string;
24
+ image?: string;
25
+ draft?: boolean;
26
+ }
27
+
28
+ export interface Tag {
29
+ name: string;
30
+ count: number;
31
+ slug: string;
32
+ }
33
+
34
+ export interface Category {
35
+ name: string;
36
+ count: number;
37
+ slug: string;
38
+ }
39
+
40
+ export interface SearchResult {
41
+ title: string;
42
+ description: string;
43
+ url: string;
44
+ content: string;
45
+ tags: string[];
46
+ categories: string[];
47
+ }
48
+
49
+ export interface NavigationItem {
50
+ name: string;
51
+ href: string;
52
+ icon?: string;
53
+ children?: NavigationItem[];
54
+ }
55
+
56
+ export interface SiteConfig {
57
+ title: string;
58
+ description: string;
59
+ author: string;
60
+ email?: string;
61
+ avatar?: string;
62
+ social?: {
63
+ github?: string;
64
+ twitter?: string;
65
+ linkedin?: string;
66
+ email?: string;
67
+ };
68
+ menu: NavigationItem[];
69
+ }
70
+
71
+ export interface SEOProps {
72
+ title?: string;
73
+ description?: string;
74
+ image?: string;
75
+ url?: string;
76
+ type?: 'website' | 'article';
77
+ publishedTime?: string;
78
+ modifiedTime?: string;
79
+ tags?: string[];
80
+ }