@jet-w/astro-blog 0.1.2 → 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.
Files changed (32) hide show
  1. package/dist/chunk-MQXPSOYB.js +124 -0
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +6 -0
  4. package/dist/integration.d.ts +25 -0
  5. package/dist/integration.js +8 -0
  6. package/package.json +2 -1
  7. package/{templates/default/src → src}/pages/rss.xml.ts +1 -1
  8. package/templates/default/astro.config.mjs +3 -1
  9. package/templates/default/src/config/footer.ts +31 -0
  10. package/templates/default/src/config/index.ts +13 -110
  11. package/templates/default/src/config/sidebar.ts +33 -0
  12. package/templates/default/src/config/site.ts +56 -0
  13. package/templates/default/src/config/social.ts +15 -0
  14. /package/{templates/default/src → src}/pages/[...slug].astro +0 -0
  15. /package/{templates/default/src → src}/pages/archives/[year]/[month]/page/[page].astro +0 -0
  16. /package/{templates/default/src → src}/pages/archives/[year]/[month].astro +0 -0
  17. /package/{templates/default/src → src}/pages/archives/index.astro +0 -0
  18. /package/{templates/default/src → src}/pages/categories/[category]/page/[page].astro +0 -0
  19. /package/{templates/default/src → src}/pages/categories/[category].astro +0 -0
  20. /package/{templates/default/src → src}/pages/categories/index.astro +0 -0
  21. /package/{templates/default/src → src}/pages/container-test.astro +0 -0
  22. /package/{templates/default/src → src}/pages/mermaid-direct.html +0 -0
  23. /package/{templates/default/src → src}/pages/posts/[...slug].astro +0 -0
  24. /package/{templates/default/src → src}/pages/posts/index.astro +0 -0
  25. /package/{templates/default/src → src}/pages/posts/page/[page].astro +0 -0
  26. /package/{templates/default/src → src}/pages/search-index.json.ts +0 -0
  27. /package/{templates/default/src → src}/pages/search.astro +0 -0
  28. /package/{templates/default/src → src}/pages/slides/[...slug].astro +0 -0
  29. /package/{templates/default/src → src}/pages/slides/index.astro +0 -0
  30. /package/{templates/default/src → src}/pages/tags/[tag]/page/[page].astro +0 -0
  31. /package/{templates/default/src → src}/pages/tags/[tag].astro +0 -0
  32. /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/index.d.ts CHANGED
@@ -4,6 +4,8 @@ import { S as SidebarConfig } from './sidebar-DNdiCKBw.js';
4
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';
5
5
  import { SiteConfig } from './types/index.js';
6
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';
7
9
 
8
10
  /**
9
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,8 @@
1
+ import {
2
+ astroBlogIntegration,
3
+ integration_default
4
+ } from "./chunk-MQXPSOYB.js";
5
+ export {
6
+ astroBlogIntegration,
7
+ integration_default as default
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jet-w/astro-blog",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "A modern Astro blog theme with Vue and Tailwind CSS support",
5
5
  "type": "module",
6
6
  "exports": {
@@ -31,6 +31,7 @@
31
31
  "src/styles",
32
32
  "src/components",
33
33
  "src/layouts",
34
+ "src/pages",
34
35
  "templates"
35
36
  ],
36
37
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  import rss from '@astrojs/rss';
2
2
  import { getCollection } from 'astro:content';
3
- import { siteConfig } from '@/config';
3
+ import { siteConfig } from '@jet-w/astro-blog/config';
4
4
 
5
5
  export async function GET(context: { site: URL }) {
6
6
  const posts = await getCollection('posts', ({ data }) => !data.draft);
@@ -7,7 +7,8 @@ import remarkMath from 'remark-math';
7
7
  import rehypeKatex from 'rehype-katex';
8
8
  import rehypeRaw from 'rehype-raw';
9
9
 
10
- // Import plugins from @jet-w/astro-blog
10
+ // Import plugins and integration from @jet-w/astro-blog
11
+ import { astroBlog } from '@jet-w/astro-blog';
11
12
  import { remarkContainers } from '@jet-w/astro-blog/plugins/remark-containers.mjs';
12
13
  import { remarkMermaid } from '@jet-w/astro-blog/plugins/remark-mermaid.mjs';
13
14
  import { rehypeCleanContainers } from '@jet-w/astro-blog/plugins/rehype-clean-containers.mjs';
@@ -17,6 +18,7 @@ import { rehypeRelativeLinks } from '@jet-w/astro-blog/plugins/rehype-relative-l
17
18
  // https://astro.build/config
18
19
  export default defineConfig({
19
20
  integrations: [
21
+ astroBlog(),
20
22
  vue(),
21
23
  mdx(),
22
24
  tailwind({
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Footer Configuration
3
+ *
4
+ * Configure footer links, copyright, and display options
5
+ */
6
+
7
+ import type { FooterConfig } from '@jet-w/astro-blog';
8
+ import { socialLinks } from './social';
9
+
10
+ /**
11
+ * Footer configuration
12
+ */
13
+ export const footerConfig: FooterConfig = {
14
+ quickLinksTitle: '快速链接',
15
+ quickLinks: [
16
+ { name: '首页', href: '/' },
17
+ { name: '文章', href: '/posts' },
18
+ { name: '标签', href: '/tags' },
19
+ { name: '归档', href: '/archives' },
20
+ { name: '关于', href: '/about' }
21
+ ],
22
+ contactTitle: '联系方式',
23
+ socialLinks: socialLinks,
24
+ showRss: true,
25
+ rssUrl: '/rss.xml',
26
+ copyright: '© {year} {author}. All rights reserved.',
27
+ poweredBy: {
28
+ text: 'Astro',
29
+ url: 'https://astro.build'
30
+ }
31
+ };
@@ -1,114 +1,17 @@
1
1
  /**
2
- * Blog configuration
2
+ * Blog Configuration
3
3
  *
4
- * Customize your blog settings here
5
- */
6
-
7
- import type { SiteConfig, NavigationItem } from '@jet-w/astro-blog';
8
- import type { SidebarConfig, FooterConfig, SocialLink } from '@jet-w/astro-blog';
9
-
10
- /**
11
- * Site configuration
12
- */
13
- export const siteConfig: SiteConfig = {
14
- title: 'My Astro Blog',
15
- description: '基于 Astro + Vue + Tailwind 构建的个人技术博客',
16
- author: 'Author',
17
- email: 'email@example.com',
18
- avatar: '/images/avatar.svg',
19
- social: {
20
- github: 'https://github.com/username',
21
- twitter: '',
22
- linkedin: '',
23
- email: 'mailto:email@example.com'
24
- },
25
- menu: [
26
- {
27
- name: '首页',
28
- href: '/',
29
- icon: 'home'
30
- },
31
- {
32
- name: '博客教学',
33
- href: '/posts/blog_docs',
34
- icon: 'posts'
35
- },
36
- {
37
- name: '演示',
38
- href: '/slides',
39
- icon: 'slides'
40
- },
41
- {
42
- name: '关于',
43
- href: '/about',
44
- icon: 'about'
45
- }
46
- ]
47
- };
48
-
49
- /**
50
- * Default SEO settings
51
- */
52
- export const defaultSEO = {
53
- title: siteConfig.title,
54
- description: siteConfig.description,
55
- image: '/images/og-image.jpg',
56
- type: 'website' as const
57
- };
58
-
59
- /**
60
- * Sidebar configuration
61
- */
62
- export const sidebarConfig: SidebarConfig = {
63
- enabled: true,
64
- showSearch: true,
65
- showRecentPosts: true,
66
- recentPostsCount: 5,
67
- showPopularTags: true,
68
- popularTagsCount: 8,
69
- showArchives: true,
70
- archivesCount: 6,
71
- showFriendLinks: false,
72
- friendLinks: [],
73
- groups: [
74
- {
75
- type: 'scan',
76
- title: '博客指南',
77
- icon: 'ri:book-open-line',
78
- scanPath: 'blog_docs',
79
- collapsed: true,
80
- showForPaths: ['/posts/blog_docs/**']
81
- }
82
- ]
83
- };
84
-
85
- /**
86
- * Social links
4
+ * This file re-exports all configuration modules for easy access.
5
+ * Each configuration is in its own file for better organization:
6
+ *
7
+ * - site.ts : Site title, description, author, menu
8
+ * - sidebar.ts : Sidebar display options and groups
9
+ * - social.ts : Social media links
10
+ * - footer.ts : Footer links and copyright
87
11
  */
88
- export const socialLinks: SocialLink[] = [
89
- { type: 'github', url: 'https://github.com/username', label: 'GitHub' },
90
- { type: 'email', url: 'mailto:email@example.com', label: 'Email' }
91
- ];
92
12
 
93
- /**
94
- * Footer configuration
95
- */
96
- export const footerConfig: FooterConfig = {
97
- quickLinksTitle: '快速链接',
98
- quickLinks: [
99
- { name: '首页', href: '/' },
100
- { name: '文章', href: '/posts' },
101
- { name: '标签', href: '/tags' },
102
- { name: '归档', href: '/archives' },
103
- { name: '关于', href: '/about' }
104
- ],
105
- contactTitle: '联系方式',
106
- socialLinks: socialLinks,
107
- showRss: true,
108
- rssUrl: '/rss.xml',
109
- copyright: '© {year} {author}. All rights reserved.',
110
- poweredBy: {
111
- text: 'Astro',
112
- url: 'https://astro.build'
113
- }
114
- };
13
+ // Re-export all configurations
14
+ export { siteConfig, defaultSEO } from './site';
15
+ export { sidebarConfig } from './sidebar';
16
+ export { socialLinks } from './social';
17
+ export { footerConfig } from './footer';
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Sidebar Configuration
3
+ *
4
+ * Configure sidebar display options, groups, and widgets
5
+ */
6
+
7
+ import type { SidebarConfig } from '@jet-w/astro-blog';
8
+
9
+ /**
10
+ * Sidebar configuration
11
+ */
12
+ export const sidebarConfig: SidebarConfig = {
13
+ enabled: true,
14
+ showSearch: true,
15
+ showRecentPosts: true,
16
+ recentPostsCount: 5,
17
+ showPopularTags: true,
18
+ popularTagsCount: 8,
19
+ showArchives: true,
20
+ archivesCount: 6,
21
+ showFriendLinks: false,
22
+ friendLinks: [],
23
+ groups: [
24
+ {
25
+ type: 'scan',
26
+ title: '博客指南',
27
+ icon: 'ri:book-open-line',
28
+ scanPath: 'blog_docs',
29
+ collapsed: true,
30
+ showForPaths: ['/posts/blog_docs/**']
31
+ }
32
+ ]
33
+ };
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Site Configuration
3
+ *
4
+ * Basic site settings including title, description, author info, etc.
5
+ */
6
+
7
+ import type { SiteConfig } from '@jet-w/astro-blog';
8
+
9
+ /**
10
+ * Site configuration
11
+ */
12
+ export const siteConfig: SiteConfig = {
13
+ title: 'My Astro Blog',
14
+ description: '基于 Astro + Vue + Tailwind 构建的个人技术博客',
15
+ author: 'Author',
16
+ email: 'email@example.com',
17
+ avatar: '/images/avatar.svg',
18
+ social: {
19
+ github: 'https://github.com/username',
20
+ twitter: '',
21
+ linkedin: '',
22
+ email: 'mailto:email@example.com'
23
+ },
24
+ menu: [
25
+ {
26
+ name: '首页',
27
+ href: '/',
28
+ icon: 'home'
29
+ },
30
+ {
31
+ name: '博客教学',
32
+ href: '/posts/blog_docs',
33
+ icon: 'posts'
34
+ },
35
+ {
36
+ name: '演示',
37
+ href: '/slides',
38
+ icon: 'slides'
39
+ },
40
+ {
41
+ name: '关于',
42
+ href: '/about',
43
+ icon: 'about'
44
+ }
45
+ ]
46
+ };
47
+
48
+ /**
49
+ * Default SEO settings
50
+ */
51
+ export const defaultSEO = {
52
+ title: siteConfig.title,
53
+ description: siteConfig.description,
54
+ image: '/images/og-image.jpg',
55
+ type: 'website' as const
56
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Social Links Configuration
3
+ *
4
+ * Configure social media links for the blog
5
+ */
6
+
7
+ import type { SocialLink } from '@jet-w/astro-blog';
8
+
9
+ /**
10
+ * Social links
11
+ */
12
+ export const socialLinks: SocialLink[] = [
13
+ { type: 'github', url: 'https://github.com/username', label: 'GitHub' },
14
+ { type: 'email', url: 'mailto:email@example.com', label: 'Email' }
15
+ ];