@jet-w/astro-blog 0.1.1 → 0.1.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.
- package/dist/chunk-MQXPSOYB.js +124 -0
- package/dist/config/index.d.ts +2 -92
- package/dist/index.d.ts +6 -2
- package/dist/index.js +6 -0
- package/dist/integration.d.ts +25 -0
- package/dist/integration.js +8 -0
- package/dist/sidebar-DNdiCKBw.d.ts +92 -0
- package/dist/utils/sidebar.d.ts +98 -0
- package/dist/utils/sidebar.js +305 -0
- package/package.json +6 -3
- package/src/components/about/SocialLinks.astro +1 -1
- package/src/components/blog/Hero.astro +1 -1
- package/src/components/layout/Footer.astro +1 -2
- package/src/components/layout/Header.astro +4 -4
- package/src/components/layout/Sidebar.astro +3 -3
- package/src/components/ui/MobileMenu.vue +1 -1
- package/src/components/ui/SearchInterface.vue +1 -1
- package/src/layouts/BaseLayout.astro +3 -3
- package/src/layouts/SlidesLayout.astro +2 -2
- package/{templates/default/src → src}/pages/rss.xml.ts +1 -1
- package/templates/default/astro.config.mjs +3 -1
- package/templates/default/src/config/footer.ts +31 -0
- package/templates/default/src/config/index.ts +13 -110
- package/templates/default/src/config/sidebar.ts +33 -0
- package/templates/default/src/config/site.ts +56 -0
- package/templates/default/src/config/social.ts +15 -0
- package/src/utils/sidebar.ts +0 -492
- /package/{templates/default/src → src}/pages/[...slug].astro +0 -0
- /package/{templates/default/src → src}/pages/archives/[year]/[month]/page/[page].astro +0 -0
- /package/{templates/default/src → src}/pages/archives/[year]/[month].astro +0 -0
- /package/{templates/default/src → src}/pages/archives/index.astro +0 -0
- /package/{templates/default/src → src}/pages/categories/[category]/page/[page].astro +0 -0
- /package/{templates/default/src → src}/pages/categories/[category].astro +0 -0
- /package/{templates/default/src → src}/pages/categories/index.astro +0 -0
- /package/{templates/default/src → src}/pages/container-test.astro +0 -0
- /package/{templates/default/src → src}/pages/mermaid-direct.html +0 -0
- /package/{templates/default/src → src}/pages/posts/[...slug].astro +0 -0
- /package/{templates/default/src → src}/pages/posts/index.astro +0 -0
- /package/{templates/default/src → src}/pages/posts/page/[page].astro +0 -0
- /package/{templates/default/src → src}/pages/search-index.json.ts +0 -0
- /package/{templates/default/src → src}/pages/search.astro +0 -0
- /package/{templates/default/src → src}/pages/slides/[...slug].astro +0 -0
- /package/{templates/default/src → src}/pages/slides/index.astro +0 -0
- /package/{templates/default/src → src}/pages/tags/[tag]/page/[page].astro +0 -0
- /package/{templates/default/src → src}/pages/tags/[tag].astro +0 -0
- /package/{templates/default/src → src}/pages/tags/index.astro +0 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// src/integration.ts
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
import path from "path";
|
|
4
|
+
var defaultOptions = {
|
|
5
|
+
routes: {
|
|
6
|
+
posts: true,
|
|
7
|
+
tags: true,
|
|
8
|
+
categories: true,
|
|
9
|
+
archives: true,
|
|
10
|
+
slides: true,
|
|
11
|
+
search: true,
|
|
12
|
+
rss: true
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
function astroBlogIntegration(options = {}) {
|
|
16
|
+
const mergedOptions = {
|
|
17
|
+
...defaultOptions,
|
|
18
|
+
routes: { ...defaultOptions.routes, ...options.routes }
|
|
19
|
+
};
|
|
20
|
+
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
21
|
+
const pagesDir = path.resolve(currentDir, "../src/pages");
|
|
22
|
+
return {
|
|
23
|
+
name: "@jet-w/astro-blog",
|
|
24
|
+
hooks: {
|
|
25
|
+
"astro:config:setup": ({ injectRoute, logger }) => {
|
|
26
|
+
logger.info("Injecting @jet-w/astro-blog routes...");
|
|
27
|
+
const routes = mergedOptions.routes;
|
|
28
|
+
if (routes.posts) {
|
|
29
|
+
injectRoute({
|
|
30
|
+
pattern: "/posts",
|
|
31
|
+
entrypoint: `${pagesDir}/posts/index.astro`
|
|
32
|
+
});
|
|
33
|
+
injectRoute({
|
|
34
|
+
pattern: "/posts/page/[page]",
|
|
35
|
+
entrypoint: `${pagesDir}/posts/page/[page].astro`
|
|
36
|
+
});
|
|
37
|
+
injectRoute({
|
|
38
|
+
pattern: "/posts/[...slug]",
|
|
39
|
+
entrypoint: `${pagesDir}/posts/[...slug].astro`
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (routes.tags) {
|
|
43
|
+
injectRoute({
|
|
44
|
+
pattern: "/tags",
|
|
45
|
+
entrypoint: `${pagesDir}/tags/index.astro`
|
|
46
|
+
});
|
|
47
|
+
injectRoute({
|
|
48
|
+
pattern: "/tags/[tag]",
|
|
49
|
+
entrypoint: `${pagesDir}/tags/[tag].astro`
|
|
50
|
+
});
|
|
51
|
+
injectRoute({
|
|
52
|
+
pattern: "/tags/[tag]/page/[page]",
|
|
53
|
+
entrypoint: `${pagesDir}/tags/[tag]/page/[page].astro`
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (routes.categories) {
|
|
57
|
+
injectRoute({
|
|
58
|
+
pattern: "/categories",
|
|
59
|
+
entrypoint: `${pagesDir}/categories/index.astro`
|
|
60
|
+
});
|
|
61
|
+
injectRoute({
|
|
62
|
+
pattern: "/categories/[category]",
|
|
63
|
+
entrypoint: `${pagesDir}/categories/[category].astro`
|
|
64
|
+
});
|
|
65
|
+
injectRoute({
|
|
66
|
+
pattern: "/categories/[category]/page/[page]",
|
|
67
|
+
entrypoint: `${pagesDir}/categories/[category]/page/[page].astro`
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (routes.archives) {
|
|
71
|
+
injectRoute({
|
|
72
|
+
pattern: "/archives",
|
|
73
|
+
entrypoint: `${pagesDir}/archives/index.astro`
|
|
74
|
+
});
|
|
75
|
+
injectRoute({
|
|
76
|
+
pattern: "/archives/[year]/[month]",
|
|
77
|
+
entrypoint: `${pagesDir}/archives/[year]/[month].astro`
|
|
78
|
+
});
|
|
79
|
+
injectRoute({
|
|
80
|
+
pattern: "/archives/[year]/[month]/page/[page]",
|
|
81
|
+
entrypoint: `${pagesDir}/archives/[year]/[month]/page/[page].astro`
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (routes.slides) {
|
|
85
|
+
injectRoute({
|
|
86
|
+
pattern: "/slides",
|
|
87
|
+
entrypoint: `${pagesDir}/slides/index.astro`
|
|
88
|
+
});
|
|
89
|
+
injectRoute({
|
|
90
|
+
pattern: "/slides/[...slug]",
|
|
91
|
+
entrypoint: `${pagesDir}/slides/[...slug].astro`
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (routes.search) {
|
|
95
|
+
injectRoute({
|
|
96
|
+
pattern: "/search",
|
|
97
|
+
entrypoint: `${pagesDir}/search.astro`
|
|
98
|
+
});
|
|
99
|
+
injectRoute({
|
|
100
|
+
pattern: "/search-index.json",
|
|
101
|
+
entrypoint: `${pagesDir}/search-index.json.ts`
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (routes.rss) {
|
|
105
|
+
injectRoute({
|
|
106
|
+
pattern: "/rss.xml",
|
|
107
|
+
entrypoint: `${pagesDir}/rss.xml.ts`
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
injectRoute({
|
|
111
|
+
pattern: "/[...slug]",
|
|
112
|
+
entrypoint: `${pagesDir}/[...slug].astro`
|
|
113
|
+
});
|
|
114
|
+
logger.info("Routes injected successfully!");
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
var integration_default = astroBlogIntegration;
|
|
120
|
+
|
|
121
|
+
export {
|
|
122
|
+
astroBlogIntegration,
|
|
123
|
+
integration_default
|
|
124
|
+
};
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SiteConfig, NavigationItem } from '../types/index.js';
|
|
2
|
+
export { D as DividerConfig, M as ManualConfig, f as MixedConfig, P as PathMatchConfig, e as ScanConfig, S as SidebarConfig, b as SidebarGroup, c as SidebarItem, d as defaultSidebarConfig, a as defineSidebarConfig, s as sidebarConfig } from '../sidebar-DNdiCKBw.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Default site configuration
|
|
@@ -27,97 +28,6 @@ declare const menu: NavigationItem[];
|
|
|
27
28
|
declare function defineMenu(items: NavigationItem[]): NavigationItem[];
|
|
28
29
|
declare const defaultMenu: NavigationItem[];
|
|
29
30
|
|
|
30
|
-
/**
|
|
31
|
-
* 侧边栏配置系统
|
|
32
|
-
*
|
|
33
|
-
* 支持三种配置类型:
|
|
34
|
-
* 1. scan - 扫描指定文件夹,自动生成树形结构
|
|
35
|
-
* 2. manual - 手动配置显示特定内容
|
|
36
|
-
* 3. mixed - 混合使用以上两种方式
|
|
37
|
-
*/
|
|
38
|
-
interface PathMatchConfig {
|
|
39
|
-
pattern: string;
|
|
40
|
-
exact?: boolean;
|
|
41
|
-
}
|
|
42
|
-
interface SidebarItem {
|
|
43
|
-
title: string;
|
|
44
|
-
slug?: string;
|
|
45
|
-
link?: string;
|
|
46
|
-
icon?: string;
|
|
47
|
-
badge?: string;
|
|
48
|
-
badgeType?: 'info' | 'success' | 'warning' | 'error';
|
|
49
|
-
children?: SidebarItem[];
|
|
50
|
-
collapsed?: boolean;
|
|
51
|
-
}
|
|
52
|
-
interface ScanConfig {
|
|
53
|
-
type: 'scan';
|
|
54
|
-
title: string;
|
|
55
|
-
icon?: string;
|
|
56
|
-
scanPath: string;
|
|
57
|
-
collapsed?: boolean;
|
|
58
|
-
maxDepth?: number;
|
|
59
|
-
exclude?: string[];
|
|
60
|
-
include?: string[];
|
|
61
|
-
sortBy?: 'name' | 'date' | 'title' | 'custom';
|
|
62
|
-
sortOrder?: 'asc' | 'desc';
|
|
63
|
-
showForPaths?: string[];
|
|
64
|
-
hideForPaths?: string[];
|
|
65
|
-
}
|
|
66
|
-
interface ManualConfig {
|
|
67
|
-
type: 'manual';
|
|
68
|
-
title: string;
|
|
69
|
-
icon?: string;
|
|
70
|
-
collapsed?: boolean;
|
|
71
|
-
items: SidebarItem[];
|
|
72
|
-
showForPaths?: string[];
|
|
73
|
-
hideForPaths?: string[];
|
|
74
|
-
}
|
|
75
|
-
interface MixedConfig {
|
|
76
|
-
type: 'mixed';
|
|
77
|
-
title: string;
|
|
78
|
-
icon?: string;
|
|
79
|
-
collapsed?: boolean;
|
|
80
|
-
sections: (ScanConfig | ManualConfig)[];
|
|
81
|
-
showForPaths?: string[];
|
|
82
|
-
hideForPaths?: string[];
|
|
83
|
-
}
|
|
84
|
-
interface DividerConfig {
|
|
85
|
-
type: 'divider';
|
|
86
|
-
title?: string;
|
|
87
|
-
showForPaths?: string[];
|
|
88
|
-
hideForPaths?: string[];
|
|
89
|
-
}
|
|
90
|
-
type SidebarGroup = ScanConfig | ManualConfig | MixedConfig | DividerConfig;
|
|
91
|
-
interface SidebarConfig {
|
|
92
|
-
enabled: boolean;
|
|
93
|
-
width?: string;
|
|
94
|
-
position?: 'left' | 'right';
|
|
95
|
-
showSearch?: boolean;
|
|
96
|
-
showRecentPosts?: boolean;
|
|
97
|
-
recentPostsCount?: number;
|
|
98
|
-
showPopularTags?: boolean;
|
|
99
|
-
popularTagsCount?: number;
|
|
100
|
-
showArchives?: boolean;
|
|
101
|
-
archivesCount?: number;
|
|
102
|
-
showFriendLinks?: boolean;
|
|
103
|
-
friendLinks?: Array<{
|
|
104
|
-
title: string;
|
|
105
|
-
url: string;
|
|
106
|
-
icon?: string;
|
|
107
|
-
description?: string;
|
|
108
|
-
}>;
|
|
109
|
-
groups: SidebarGroup[];
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* 默认侧边栏配置
|
|
113
|
-
*/
|
|
114
|
-
declare const sidebarConfig: SidebarConfig;
|
|
115
|
-
/**
|
|
116
|
-
* Define sidebar configuration
|
|
117
|
-
*/
|
|
118
|
-
declare function defineSidebarConfig(config: Partial<SidebarConfig>): SidebarConfig;
|
|
119
|
-
declare const defaultSidebarConfig: SidebarConfig;
|
|
120
|
-
|
|
121
31
|
/**
|
|
122
32
|
* 社交链接配置
|
|
123
33
|
*/
|
|
@@ -163,4 +73,4 @@ declare const footerConfig: FooterConfig;
|
|
|
163
73
|
declare function defineFooterConfig(config: Partial<FooterConfig>): FooterConfig;
|
|
164
74
|
declare const defaultFooterConfig: FooterConfig;
|
|
165
75
|
|
|
166
|
-
export { type
|
|
76
|
+
export { type FooterConfig, type FooterLink, type SocialLink, defaultFooterConfig, defaultIcons, defaultMenu, defaultSEO, defaultSiteConfig, defaultSocialLinks, defineFooterConfig, defineMenu, defineSiteConfig, defineSocialLinks, footerConfig, menu, siteConfig, socialLinks };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { FooterConfig, SocialLink } from './config/index.js';
|
|
2
|
+
export { FooterLink, defaultFooterConfig, defaultIcons, defaultMenu, defaultSEO, defaultSiteConfig, defaultSocialLinks, defineFooterConfig, defineMenu, defineSiteConfig, defineSocialLinks, footerConfig, menu, siteConfig, socialLinks } from './config/index.js';
|
|
3
|
+
import { S as SidebarConfig } from './sidebar-DNdiCKBw.js';
|
|
4
|
+
export { D as DividerConfig, M as ManualConfig, f as MixedConfig, P as PathMatchConfig, e as ScanConfig, b as SidebarGroup, c as SidebarItem, d as defaultSidebarConfig, a as defineSidebarConfig, s as sidebarConfig } from './sidebar-DNdiCKBw.js';
|
|
3
5
|
import { SiteConfig } from './types/index.js';
|
|
4
6
|
export { BlogPost, Category, NavigationItem, PostFrontmatter, SEOProps, SearchResult, Tag } from './types/index.js';
|
|
7
|
+
export { AstroBlogIntegrationOptions, default as astroBlog, default as astroBlogIntegration } from './integration.js';
|
|
8
|
+
import 'astro';
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
11
|
* Define blog configuration helper
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,10 @@ import {
|
|
|
18
18
|
socialLinks
|
|
19
19
|
} from "./chunk-GYLSY3OJ.js";
|
|
20
20
|
import "./chunk-FXPGR372.js";
|
|
21
|
+
import {
|
|
22
|
+
astroBlogIntegration,
|
|
23
|
+
integration_default
|
|
24
|
+
} from "./chunk-MQXPSOYB.js";
|
|
21
25
|
|
|
22
26
|
// src/index.ts
|
|
23
27
|
function defineBlogConfig(config) {
|
|
@@ -37,6 +41,8 @@ function getAstroConfig(options) {
|
|
|
37
41
|
};
|
|
38
42
|
}
|
|
39
43
|
export {
|
|
44
|
+
integration_default as astroBlog,
|
|
45
|
+
astroBlogIntegration,
|
|
40
46
|
defaultFooterConfig,
|
|
41
47
|
defaultIcons,
|
|
42
48
|
defaultMenu,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AstroIntegration } from 'astro';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @jet-w/astro-blog Integration
|
|
5
|
+
*
|
|
6
|
+
* This integration injects the blog pages into your Astro project
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
interface AstroBlogIntegrationOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Enable/disable specific page routes
|
|
12
|
+
*/
|
|
13
|
+
routes?: {
|
|
14
|
+
posts?: boolean;
|
|
15
|
+
tags?: boolean;
|
|
16
|
+
categories?: boolean;
|
|
17
|
+
archives?: boolean;
|
|
18
|
+
slides?: boolean;
|
|
19
|
+
search?: boolean;
|
|
20
|
+
rss?: boolean;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
declare function astroBlogIntegration(options?: AstroBlogIntegrationOptions): AstroIntegration;
|
|
24
|
+
|
|
25
|
+
export { type AstroBlogIntegrationOptions, astroBlogIntegration, astroBlogIntegration as default };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 侧边栏配置系统
|
|
3
|
+
*
|
|
4
|
+
* 支持三种配置类型:
|
|
5
|
+
* 1. scan - 扫描指定文件夹,自动生成树形结构
|
|
6
|
+
* 2. manual - 手动配置显示特定内容
|
|
7
|
+
* 3. mixed - 混合使用以上两种方式
|
|
8
|
+
*/
|
|
9
|
+
interface PathMatchConfig {
|
|
10
|
+
pattern: string;
|
|
11
|
+
exact?: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface SidebarItem {
|
|
14
|
+
title: string;
|
|
15
|
+
slug?: string;
|
|
16
|
+
link?: string;
|
|
17
|
+
icon?: string;
|
|
18
|
+
badge?: string;
|
|
19
|
+
badgeType?: 'info' | 'success' | 'warning' | 'error';
|
|
20
|
+
children?: SidebarItem[];
|
|
21
|
+
collapsed?: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface ScanConfig {
|
|
24
|
+
type: 'scan';
|
|
25
|
+
title: string;
|
|
26
|
+
icon?: string;
|
|
27
|
+
scanPath: string;
|
|
28
|
+
collapsed?: boolean;
|
|
29
|
+
maxDepth?: number;
|
|
30
|
+
exclude?: string[];
|
|
31
|
+
include?: string[];
|
|
32
|
+
sortBy?: 'name' | 'date' | 'title' | 'custom';
|
|
33
|
+
sortOrder?: 'asc' | 'desc';
|
|
34
|
+
showForPaths?: string[];
|
|
35
|
+
hideForPaths?: string[];
|
|
36
|
+
}
|
|
37
|
+
interface ManualConfig {
|
|
38
|
+
type: 'manual';
|
|
39
|
+
title: string;
|
|
40
|
+
icon?: string;
|
|
41
|
+
collapsed?: boolean;
|
|
42
|
+
items: SidebarItem[];
|
|
43
|
+
showForPaths?: string[];
|
|
44
|
+
hideForPaths?: string[];
|
|
45
|
+
}
|
|
46
|
+
interface MixedConfig {
|
|
47
|
+
type: 'mixed';
|
|
48
|
+
title: string;
|
|
49
|
+
icon?: string;
|
|
50
|
+
collapsed?: boolean;
|
|
51
|
+
sections: (ScanConfig | ManualConfig)[];
|
|
52
|
+
showForPaths?: string[];
|
|
53
|
+
hideForPaths?: string[];
|
|
54
|
+
}
|
|
55
|
+
interface DividerConfig {
|
|
56
|
+
type: 'divider';
|
|
57
|
+
title?: string;
|
|
58
|
+
showForPaths?: string[];
|
|
59
|
+
hideForPaths?: string[];
|
|
60
|
+
}
|
|
61
|
+
type SidebarGroup = ScanConfig | ManualConfig | MixedConfig | DividerConfig;
|
|
62
|
+
interface SidebarConfig {
|
|
63
|
+
enabled: boolean;
|
|
64
|
+
width?: string;
|
|
65
|
+
position?: 'left' | 'right';
|
|
66
|
+
showSearch?: boolean;
|
|
67
|
+
showRecentPosts?: boolean;
|
|
68
|
+
recentPostsCount?: number;
|
|
69
|
+
showPopularTags?: boolean;
|
|
70
|
+
popularTagsCount?: number;
|
|
71
|
+
showArchives?: boolean;
|
|
72
|
+
archivesCount?: number;
|
|
73
|
+
showFriendLinks?: boolean;
|
|
74
|
+
friendLinks?: Array<{
|
|
75
|
+
title: string;
|
|
76
|
+
url: string;
|
|
77
|
+
icon?: string;
|
|
78
|
+
description?: string;
|
|
79
|
+
}>;
|
|
80
|
+
groups: SidebarGroup[];
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 默认侧边栏配置
|
|
84
|
+
*/
|
|
85
|
+
declare const sidebarConfig: SidebarConfig;
|
|
86
|
+
/**
|
|
87
|
+
* Define sidebar configuration
|
|
88
|
+
*/
|
|
89
|
+
declare function defineSidebarConfig(config: Partial<SidebarConfig>): SidebarConfig;
|
|
90
|
+
declare const defaultSidebarConfig: SidebarConfig;
|
|
91
|
+
|
|
92
|
+
export { type DividerConfig as D, type ManualConfig as M, type PathMatchConfig as P, type SidebarConfig as S, defineSidebarConfig as a, type SidebarGroup as b, type SidebarItem as c, defaultSidebarConfig as d, type ScanConfig as e, type MixedConfig as f, sidebarConfig as s };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { c as SidebarItem, b as SidebarGroup, S as SidebarConfig } from '../sidebar-DNdiCKBw.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 侧边栏工具函数
|
|
5
|
+
* 处理配置解析和树形结构生成
|
|
6
|
+
*/
|
|
7
|
+
interface PostEntry {
|
|
8
|
+
id: string;
|
|
9
|
+
data: {
|
|
10
|
+
title?: string;
|
|
11
|
+
icon?: string;
|
|
12
|
+
pubDate?: Date;
|
|
13
|
+
tags?: string[];
|
|
14
|
+
draft?: boolean;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface TreeNode {
|
|
19
|
+
name: string;
|
|
20
|
+
slug?: string;
|
|
21
|
+
title?: string;
|
|
22
|
+
displayName?: string;
|
|
23
|
+
icon?: string;
|
|
24
|
+
badge?: string;
|
|
25
|
+
badgeType?: 'info' | 'success' | 'warning' | 'error';
|
|
26
|
+
children: TreeNode[];
|
|
27
|
+
isFolder: boolean;
|
|
28
|
+
isReadme?: boolean;
|
|
29
|
+
link?: string;
|
|
30
|
+
collapsed?: boolean;
|
|
31
|
+
}
|
|
32
|
+
interface ProcessedGroup {
|
|
33
|
+
type: 'tree' | 'items' | 'divider';
|
|
34
|
+
title: string;
|
|
35
|
+
icon?: string;
|
|
36
|
+
collapsed?: boolean;
|
|
37
|
+
tree?: TreeNode[];
|
|
38
|
+
items?: SidebarItem[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 从文章集合构建树形结构
|
|
42
|
+
*/
|
|
43
|
+
declare function buildTreeFromPosts(posts: PostEntry[], scanPath?: string, options?: {
|
|
44
|
+
maxDepth?: number;
|
|
45
|
+
exclude?: string[];
|
|
46
|
+
include?: string[];
|
|
47
|
+
sortBy?: 'name' | 'date' | 'title' | 'custom';
|
|
48
|
+
sortOrder?: 'asc' | 'desc';
|
|
49
|
+
}): TreeNode[];
|
|
50
|
+
/**
|
|
51
|
+
* 路径 glob 模式匹配
|
|
52
|
+
* 支持:
|
|
53
|
+
* - /posts/tech/** 匹配 /posts/tech 及其所有子路径
|
|
54
|
+
* - /posts/tech/* 匹配 /posts/tech 的直接子路径
|
|
55
|
+
* - /posts/tech 精确匹配
|
|
56
|
+
*/
|
|
57
|
+
declare function matchPathPattern(currentPath: string, pattern: string): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* 检查侧边栏组是否应该在当前路径显示
|
|
60
|
+
*/
|
|
61
|
+
declare function shouldShowGroup(group: {
|
|
62
|
+
showForPaths?: string[];
|
|
63
|
+
hideForPaths?: string[];
|
|
64
|
+
}, currentPath: string): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* 根据当前路径过滤侧边栏组
|
|
67
|
+
*/
|
|
68
|
+
declare function filterGroupsByPath(groups: SidebarGroup[], currentPath: string): SidebarGroup[];
|
|
69
|
+
/**
|
|
70
|
+
* 将手动配置的项目转换为树节点
|
|
71
|
+
*/
|
|
72
|
+
declare function manualItemsToTree(items: SidebarItem[]): TreeNode[];
|
|
73
|
+
/**
|
|
74
|
+
* 处理侧边栏配置,生成可渲染的数据结构
|
|
75
|
+
*/
|
|
76
|
+
declare function processSidebarConfig(config: SidebarConfig, posts: PostEntry[]): Promise<ProcessedGroup[]>;
|
|
77
|
+
/**
|
|
78
|
+
* 获取最新文章
|
|
79
|
+
*/
|
|
80
|
+
declare function getRecentPosts(posts: PostEntry[], count?: number): PostEntry[];
|
|
81
|
+
/**
|
|
82
|
+
* 获取热门标签
|
|
83
|
+
*/
|
|
84
|
+
declare function getPopularTags(posts: PostEntry[], count?: number): Array<{
|
|
85
|
+
name: string;
|
|
86
|
+
count: number;
|
|
87
|
+
slug: string;
|
|
88
|
+
}>;
|
|
89
|
+
/**
|
|
90
|
+
* 获取归档数据
|
|
91
|
+
*/
|
|
92
|
+
declare function getArchives(posts: PostEntry[], count?: number): Array<{
|
|
93
|
+
year: number;
|
|
94
|
+
month: number;
|
|
95
|
+
count: number;
|
|
96
|
+
}>;
|
|
97
|
+
|
|
98
|
+
export { type ProcessedGroup, type TreeNode, buildTreeFromPosts, filterGroupsByPath, getArchives, getPopularTags, getRecentPosts, manualItemsToTree, matchPathPattern, processSidebarConfig, shouldShowGroup };
|