@jet-w/astro-blog 0.2.0 → 0.2.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.
Files changed (121) hide show
  1. package/dist/{chunk-HVQKQN6B.js → chunk-6D3XRDNY.js} +1 -1
  2. package/dist/{chunk-ATRISB7B.js → chunk-A2E2VSAQ.js} +43 -3
  3. package/dist/chunk-DAH2XP4W.js +154 -0
  4. package/dist/{chunk-AZHCNNAC.js → chunk-PG43JO4O.js} +1 -153
  5. package/dist/chunk-PZICDGJG.js +69 -0
  6. package/dist/chunk-Z3O3JK56.js +186 -0
  7. package/dist/config/index.d.ts +2 -2
  8. package/dist/config/index.js +9 -7
  9. package/dist/{i18n-5H4W145i.d.ts → i18n-DYYPTq4o.d.ts} +21 -1
  10. package/dist/index.d.ts +10 -184
  11. package/dist/index.js +37 -210
  12. package/dist/integration.d.ts +2 -2
  13. package/dist/integration.js +2 -2
  14. package/dist/{sidebar-Da-W_4Lr.d.ts → sidebar-DNdiCKBw.d.ts} +1 -1
  15. package/dist/utils/i18n.d.ts +133 -0
  16. package/dist/utils/i18n.js +49 -0
  17. package/dist/utils/sidebar.d.ts +1 -1
  18. package/dist/utils/useI18n.d.ts +74 -0
  19. package/dist/utils/useI18n.js +15 -0
  20. package/package.json +9 -1
  21. package/src/components/blog/FloatingToc.vue +11 -3
  22. package/src/components/blog/Hero.astro +17 -2
  23. package/src/components/blog/NavigationTabs.vue +46 -15
  24. package/src/components/blog/PostCard.astro +28 -10
  25. package/src/components/blog/RelatedPosts.astro +23 -7
  26. package/src/components/blog/TableOfContents.astro +10 -4
  27. package/src/components/blog/TagCloud.astro +4 -3
  28. package/src/components/home/FeaturedPostsSection.astro +22 -6
  29. package/src/components/home/QuickNavSection.astro +33 -4
  30. package/src/components/home/RecentPostsSection.astro +22 -6
  31. package/src/components/home/StatsSection.astro +24 -6
  32. package/src/components/layout/Header.astro +9 -5
  33. package/src/components/layout/Sidebar.astro +14 -11
  34. package/src/components/ui/SearchBox.vue +13 -5
  35. package/src/components/ui/SearchInterface.vue +49 -25
  36. package/src/pages/archives/[year]/[month].astro +36 -17
  37. package/src/pages/archives/index.astro +36 -20
  38. package/src/pages/categories/[category].astro +33 -16
  39. package/src/pages/categories/index.astro +37 -14
  40. package/src/pages/posts/[...slug].astro +125 -18
  41. package/src/pages/posts/index.astro +59 -37
  42. package/src/pages/posts/page/[page].astro +65 -27
  43. package/src/pages/search.astro +50 -14
  44. package/src/pages/slides/index.astro +25 -6
  45. package/src/pages/tags/[tag].astro +32 -15
  46. package/src/pages/tags/index.astro +39 -16
  47. package/src/plugins/remark-containers.mjs +351 -322
  48. package/src/plugins/remark-protect-code.mjs +69 -0
  49. package/src/styles/global.css +35 -1
  50. package/templates/default/.claude/ralph-loop.local.md +48 -0
  51. package/templates/default/astro.config.mjs +13 -4
  52. package/templates/default/content/posts/blog_docs_en/{get-started → 01.get-started}/01-intro.md +1 -1
  53. package/templates/default/content/posts/blog_docs_en/{get-started → 01.get-started}/02-install.md +1 -1
  54. package/templates/default/content/posts/blog_docs_en/{get-started → 01.get-started}/03-create-post.md +1 -1
  55. package/templates/default/content/posts/blog_docs_en/{get-started → 01.get-started}/04-structure.md +1 -1
  56. package/templates/default/content/posts/blog_docs_en/01.get-started/05-deploy.md +208 -0
  57. package/templates/default/content/posts/blog_docs_en/{get-started → 01.get-started}/README.md +1 -1
  58. package/templates/default/content/posts/blog_docs_en/02.guide/02-containers.md +245 -0
  59. package/templates/default/content/posts/blog_docs_en/{guide/markdown → 02.guide}/03-code-blocks.md +2 -1
  60. package/templates/default/content/posts/blog_docs_en/{guide/features/01-mermaid.md → 02.guide/03-mermaid.md} +1 -1
  61. package/templates/default/content/posts/blog_docs_en/{guide/features → 02.guide}/04-icons.md +4 -2
  62. package/templates/default/content/posts/blog_docs_en/{guide/features/02-latex.md → 02.guide/06-latex.md} +1 -1
  63. package/templates/default/content/posts/blog_docs_en/{guide/features/03-video.md → 02.guide/07-video.md} +1 -1
  64. package/templates/default/content/posts/blog_docs_en/02.guide/08-slides.md +359 -0
  65. package/templates/default/content/posts/blog_docs_en/{guide/markdown → 02.guide}/README.md +22 -3
  66. package/templates/default/content/posts/blog_docs_en/{config → 03.config}/01-site.md +1 -1
  67. package/templates/default/content/posts/blog_docs_en/{config → 03.config}/02-sidebar.md +1 -1
  68. package/templates/default/content/posts/blog_docs_en/{config → 03.config}/03-i18n.md +88 -24
  69. package/templates/default/content/posts/blog_docs_en/{config → 03.config}/README.md +1 -1
  70. package/templates/default/content/posts/blog_docs_en/README.md +2 -1
  71. package/templates/default/content/posts/blog_docs_zh/01.get-started/01-intro.md +81 -0
  72. package/templates/default/content/posts/blog_docs_zh/01.get-started/02-install.md +137 -0
  73. package/templates/default/content/posts/blog_docs_zh/01.get-started/03-create-post.md +176 -0
  74. package/templates/default/content/posts/blog_docs_zh/01.get-started/04-structure.md +173 -0
  75. package/templates/default/content/posts/blog_docs_zh/01.get-started/05-deploy.md +208 -0
  76. package/templates/default/content/posts/blog_docs_zh/01.get-started/README.md +52 -0
  77. package/templates/default/content/posts/blog_docs_zh/02.guide/02-containers.md +245 -0
  78. package/templates/default/content/posts/blog_docs_zh/02.guide/03-code-blocks.md +206 -0
  79. package/templates/default/content/posts/blog_docs_zh/02.guide/03-mermaid.md +194 -0
  80. package/templates/default/content/posts/blog_docs_zh/02.guide/04-icons.md +229 -0
  81. package/templates/default/content/posts/blog_docs_zh/02.guide/06-latex.md +233 -0
  82. package/templates/default/content/posts/blog_docs_zh/02.guide/07-video.md +184 -0
  83. package/templates/default/content/posts/blog_docs_zh/02.guide/08-slides.md +359 -0
  84. package/templates/default/content/posts/blog_docs_zh/02.guide/README.md +213 -0
  85. package/templates/default/content/posts/blog_docs_zh/03.config/01-site.md +208 -0
  86. package/templates/default/content/posts/blog_docs_zh/03.config/02-sidebar.md +240 -0
  87. package/templates/default/content/posts/blog_docs_zh/03.config/03-i18n.md +348 -0
  88. package/templates/default/content/posts/blog_docs_zh/03.config/README.md +85 -0
  89. package/templates/default/content/posts/blog_docs_zh/README.md +78 -0
  90. package/templates/default/package.dev.json +31 -0
  91. package/templates/default/package.json +1 -1
  92. package/templates/default/src/config/locales/en/index.ts +5 -1
  93. package/templates/default/src/config/locales/en/menu.ts +3 -1
  94. package/templates/default/src/config/locales/en/sidebar.ts +18 -2
  95. package/templates/default/src/config/locales/en/site.ts +1 -1
  96. package/templates/default/src/config/locales/en/ui.ts +29 -0
  97. package/templates/default/src/config/locales/zh-CN/index.ts +5 -1
  98. package/templates/default/src/config/locales/zh-CN/menu.ts +7 -5
  99. package/templates/default/src/config/locales/zh-CN/sidebar.ts +22 -6
  100. package/templates/default/src/config/locales/zh-CN/site.ts +2 -2
  101. package/templates/default/src/config/locales/zh-CN/ui.ts +29 -0
  102. package/templates/default/src/config/site.ts +2 -2
  103. package/templates/default/src/content.config.ts +15 -3
  104. package/templates/default/content/posts/blog_docs/01-quick-start.md +0 -162
  105. package/templates/default/content/posts/blog_docs/02-frontmatter.md +0 -277
  106. package/templates/default/content/posts/blog_docs/03-markdown-basic.md +0 -350
  107. package/templates/default/content/posts/blog_docs/04-containers.md +0 -331
  108. package/templates/default/content/posts/blog_docs/05-code-blocks.md +0 -388
  109. package/templates/default/content/posts/blog_docs/06-mermaid.md +0 -431
  110. package/templates/default/content/posts/blog_docs/07-video.md +0 -243
  111. package/templates/default/content/posts/blog_docs/08-latex.md +0 -382
  112. package/templates/default/content/posts/blog_docs/09-icons.md +0 -326
  113. package/templates/default/content/posts/blog_docs/10-sidebar.md +0 -445
  114. package/templates/default/content/posts/blog_docs/11-config.md +0 -334
  115. package/templates/default/content/posts/blog_docs/12-i18n.md +0 -355
  116. package/templates/default/content/posts/blog_docs/12-slides.mdx +0 -552
  117. package/templates/default/content/posts/blog_docs/README.md +0 -152
  118. package/templates/default/content/posts/blog_docs_en/get-started/05-deploy.md +0 -197
  119. package/templates/default/content/posts/blog_docs_en/guide/README.md +0 -59
  120. package/templates/default/content/posts/blog_docs_en/guide/features/README.md +0 -51
  121. package/templates/default/content/posts/blog_docs_en/guide/markdown/02-containers.md +0 -226
@@ -1,22 +1,24 @@
1
1
  import {
2
- defaultFooterConfig,
3
2
  defaultIcons,
3
+ defaultSocialLinks,
4
+ defineSocialLinks,
5
+ socialLinks
6
+ } from "../chunk-PG43JO4O.js";
7
+ import {
8
+ defaultFooterConfig,
4
9
  defaultMenu,
5
10
  defaultSEO,
6
11
  defaultSidebarConfig,
7
12
  defaultSiteConfig,
8
- defaultSocialLinks,
9
13
  defineFooterConfig,
10
14
  defineMenu,
11
15
  defineSidebarConfig,
12
16
  defineSiteConfig,
13
- defineSocialLinks,
14
17
  footerConfig,
15
18
  menu,
16
19
  sidebarConfig,
17
- siteConfig,
18
- socialLinks
19
- } from "../chunk-AZHCNNAC.js";
20
+ siteConfig
21
+ } from "../chunk-DAH2XP4W.js";
20
22
  import {
21
23
  builtInTranslations,
22
24
  defaultI18nConfig,
@@ -25,7 +27,7 @@ import {
25
27
  enTranslations,
26
28
  getUITranslations,
27
29
  zhCNTranslations
28
- } from "../chunk-ATRISB7B.js";
30
+ } from "../chunk-A2E2VSAQ.js";
29
31
  export {
30
32
  builtInTranslations,
31
33
  defaultFooterConfig,
@@ -1,5 +1,5 @@
1
1
  import { SiteConfig, NavigationItem } from './types/index.js';
2
- import { b as SidebarConfig } from './sidebar-Da-W_4Lr.js';
2
+ import { S as SidebarConfig } from './sidebar-DNdiCKBw.js';
3
3
 
4
4
  /**
5
5
  * 社交链接配置
@@ -99,6 +99,19 @@ interface UITranslations {
99
99
  searchResults: string;
100
100
  noResults: string;
101
101
  searching: string;
102
+ searchArticles: string;
103
+ searchInAllArticles: string;
104
+ searchTips: string;
105
+ basicSearch: string;
106
+ advancedFeatures: string;
107
+ searchTipKeyword: string;
108
+ searchTipMixedLang: string;
109
+ searchTipCaseInsensitive: string;
110
+ searchTipRealtime: string;
111
+ searchTipFilter: string;
112
+ searchTipFuzzy: string;
113
+ browsePosts: string;
114
+ aboutMe: string;
102
115
  previousPage: string;
103
116
  nextPage: string;
104
117
  page: string;
@@ -107,6 +120,7 @@ interface UITranslations {
107
120
  updatedOn: string;
108
121
  author: string;
109
122
  tableOfContents: string;
123
+ readingProgress: string;
110
124
  relatedPosts: string;
111
125
  sharePost: string;
112
126
  previousPost: string;
@@ -133,6 +147,10 @@ interface UITranslations {
133
147
  slides: string;
134
148
  slidesList: string;
135
149
  rssFeed: string;
150
+ quickNavigation: string;
151
+ timeline: string;
152
+ viewAllTimeline: string;
153
+ postsCount: string;
136
154
  }
137
155
  /**
138
156
  * Locale-specific configuration
@@ -148,6 +166,8 @@ interface LocaleConfig {
148
166
  sidebar?: Partial<SidebarConfig>;
149
167
  /** UI translation overrides */
150
168
  ui?: Partial<UITranslations>;
169
+ /** Content path prefix for filtering posts by locale (e.g., 'blog_docs_en' for English) */
170
+ contentPathPrefix?: string;
151
171
  }
152
172
  /**
153
173
  * i18n routing configuration
package/dist/index.d.ts CHANGED
@@ -1,189 +1,15 @@
1
1
  export { defaultMenu, defaultSEO, defaultSiteConfig, defineMenu, defineSiteConfig, menu, siteConfig } from './config/index.js';
2
- import { b as SidebarConfig } from './sidebar-Da-W_4Lr.js';
3
- export { D as DividerConfig, M as ManualConfig, f as MixedConfig, P as PathMatchConfig, e as ScanConfig, a as SidebarGroup, S as SidebarItem, d as defaultSidebarConfig, c as defineSidebarConfig, s as sidebarConfig } from './sidebar-Da-W_4Lr.js';
4
- import { I as I18nConfig, L as Locale, F as FooterConfig, U as UITranslations, S as SocialLink } from './i18n-5H4W145i.js';
5
- export { m as FooterLink, o as I18nRoutingConfig, n as LocaleConfig, j as builtInTranslations, c as defaultFooterConfig, g as defaultI18nConfig, d as defaultIcons, l as defaultLocales, a as defaultSocialLinks, e as defineFooterConfig, h as defineI18nConfig, b as defineSocialLinks, k as enTranslations, f as footerConfig, i as getUITranslations, s as socialLinks, z as zhCNTranslations } from './i18n-5H4W145i.js';
6
- import { SiteConfig, NavigationItem } from './types/index.js';
7
- export { BlogPost, Category, PostFrontmatter, SEOProps, SearchResult, Tag } from './types/index.js';
2
+ import { S as SidebarConfig } from './sidebar-DNdiCKBw.js';
3
+ 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';
4
+ import { F as FooterConfig, S as SocialLink, I as I18nConfig } from './i18n-DYYPTq4o.js';
5
+ export { m as FooterLink, o as I18nRoutingConfig, L as Locale, n as LocaleConfig, U as UITranslations, j as builtInTranslations, c as defaultFooterConfig, g as defaultI18nConfig, d as defaultIcons, l as defaultLocales, a as defaultSocialLinks, e as defineFooterConfig, h as defineI18nConfig, b as defineSocialLinks, k as enTranslations, f as footerConfig, i as getUITranslations, s as socialLinks, z as zhCNTranslations } from './i18n-DYYPTq4o.js';
6
+ import { SiteConfig } from './types/index.js';
7
+ export { BlogPost, Category, NavigationItem, PostFrontmatter, SEOProps, SearchResult, Tag } from './types/index.js';
8
8
  export { AstroBlogIntegrationOptions, default as astroBlog, default as astroBlogIntegration } from './integration.js';
9
- import { ComputedRef } from 'vue';
9
+ export { AlternateLink, MergedLocaleConfig, filterPostsByLocale, formatDate, formatDateShort, getAlternateLinks, getContentPathPrefix, getLocaleByCode, getLocaleConfig, getLocaleFromPath, getLocalePrefix, getLocalizedPath, getTextDirection, isMultiLanguageEnabled, isRTL, removeLocalePrefix, t } from './utils/i18n.js';
10
+ export { I18N_CONFIG_KEY, I18N_LOCALE_KEY, I18N_TRANSLATIONS_KEY, I18nContext, UseI18nReturn, createI18nContext, useI18n } from './utils/useI18n.js';
10
11
  import 'astro';
11
-
12
- /**
13
- * i18n Utility Functions
14
- *
15
- * Provides helper functions for multi-language support.
16
- */
17
-
18
- /**
19
- * Merged locale configuration with all defaults applied
20
- */
21
- interface MergedLocaleConfig {
22
- locale: Locale;
23
- site: SiteConfig;
24
- menu: NavigationItem[];
25
- footer: FooterConfig;
26
- sidebar: SidebarConfig;
27
- ui: UITranslations;
28
- }
29
- /**
30
- * Alternate link for SEO (hreflang)
31
- */
32
- interface AlternateLink {
33
- locale: string;
34
- url: string;
35
- hreflang: string;
36
- }
37
- /**
38
- * Get current locale from URL pathname
39
- *
40
- * @example
41
- * getLocaleFromPath('/en/posts', config) // 'en'
42
- * getLocaleFromPath('/posts', config) // 'zh-CN' (default)
43
- * getLocaleFromPath('/zh-CN/about', config) // 'zh-CN'
44
- */
45
- declare function getLocaleFromPath(pathname: string, config?: I18nConfig): string;
46
- /**
47
- * Get locale data by code
48
- */
49
- declare function getLocaleByCode(code: string, config?: I18nConfig): Locale | undefined;
50
- /**
51
- * Remove locale prefix from pathname
52
- *
53
- * @example
54
- * removeLocalePrefix('/en/posts', config) // '/posts'
55
- * removeLocalePrefix('/posts', config) // '/posts'
56
- */
57
- declare function removeLocalePrefix(pathname: string, config?: I18nConfig): string;
58
- /**
59
- * Get localized path for a given locale
60
- *
61
- * @example
62
- * getLocalizedPath('/posts', 'en', config) // '/en/posts'
63
- * getLocalizedPath('/en/posts', 'zh-CN', config) // '/posts' (if zh-CN is default)
64
- */
65
- declare function getLocalizedPath(pathname: string, targetLocale: string, config?: I18nConfig): string;
66
- /**
67
- * Get all alternate links for SEO (hreflang tags)
68
- *
69
- * @example
70
- * getAlternateLinks('/posts', 'https://example.com', config)
71
- * // Returns links for all locales
72
- */
73
- declare function getAlternateLinks(pathname: string, baseUrl: string, config?: I18nConfig): AlternateLink[];
74
- /**
75
- * Get merged configuration for a specific locale
76
- * Combines default config with locale-specific overrides
77
- */
78
- declare function getLocaleConfig(locale: string, config?: I18nConfig): MergedLocaleConfig;
79
- /**
80
- * Translation function - get a UI translation string
81
- *
82
- * @example
83
- * t('readMore', 'en') // 'Read more'
84
- * t('readMore', 'zh-CN') // '阅读更多'
85
- */
86
- declare function t(key: keyof UITranslations, locale: string, config?: I18nConfig): string;
87
- /**
88
- * Format date according to locale
89
- *
90
- * @example
91
- * formatDate(new Date(), 'en') // 'January 1, 2024'
92
- * formatDate(new Date(), 'zh-CN') // '2024年1月1日'
93
- */
94
- declare function formatDate(date: Date | string, locale: string, options?: Intl.DateTimeFormatOptions): string;
95
- /**
96
- * Format date in short format
97
- *
98
- * @example
99
- * formatDateShort(new Date(), 'en') // '1/1/2024'
100
- * formatDateShort(new Date(), 'zh-CN') // '2024/1/1'
101
- */
102
- declare function formatDateShort(date: Date | string, locale: string): string;
103
- /**
104
- * Check if a locale is RTL (right-to-left)
105
- */
106
- declare function isRTL(locale: string, config?: I18nConfig): boolean;
107
- /**
108
- * Get the HTML dir attribute value
109
- */
110
- declare function getTextDirection(locale: string, config?: I18nConfig): 'ltr' | 'rtl';
111
- /**
112
- * Check if multi-language is enabled (more than one locale)
113
- */
114
- declare function isMultiLanguageEnabled(config?: I18nConfig): boolean;
115
- /**
116
- * Get prefix for a locale in routes
117
- * Returns empty string for default locale if prefixDefaultLocale is false
118
- */
119
- declare function getLocalePrefix(locale: string, config?: I18nConfig): string;
120
-
121
- /**
122
- * Vue Composable for i18n
123
- *
124
- * Provides i18n support for Vue components in the blog.
125
- */
126
-
127
- /**
128
- * i18n injection keys
129
- */
130
- declare const I18N_LOCALE_KEY: unique symbol;
131
- declare const I18N_CONFIG_KEY: unique symbol;
132
- declare const I18N_TRANSLATIONS_KEY: unique symbol;
133
- /**
134
- * i18n context provided to Vue components
135
- */
136
- interface I18nContext {
137
- locale: string;
138
- translations: UITranslations;
139
- config?: I18nConfig;
140
- }
141
- /**
142
- * Return type of useI18n composable
143
- */
144
- interface UseI18nReturn {
145
- /** Current locale code */
146
- locale: ComputedRef<string>;
147
- /** Translation function */
148
- t: (key: keyof UITranslations) => string;
149
- /** Format date according to locale */
150
- formatDate: (date: Date | string, options?: Intl.DateTimeFormatOptions) => string;
151
- /** Format date in short format */
152
- formatDateShort: (date: Date | string) => string;
153
- /** All translations for current locale */
154
- translations: ComputedRef<UITranslations>;
155
- }
156
- /**
157
- * Vue composable for i18n support
158
- *
159
- * @example
160
- * ```vue
161
- * <script setup>
162
- * import { useI18n } from '@jet-w/astro-blog/utils/useI18n';
163
- *
164
- * const { t, formatDate, locale } = useI18n();
165
- * </script>
166
- *
167
- * <template>
168
- * <h1>{{ t('postList') }}</h1>
169
- * <span>{{ formatDate(post.pubDate) }}</span>
170
- * </template>
171
- * ```
172
- */
173
- declare function useI18n(): UseI18nReturn;
174
- /**
175
- * Create i18n context for providing to Vue components
176
- *
177
- * @example
178
- * ```astro
179
- * ---
180
- * import { createI18nContext } from '@jet-w/astro-blog/utils/useI18n';
181
- * const i18nContext = createI18nContext('en', i18nConfig);
182
- * ---
183
- * <Component client:load {...i18nContext} />
184
- * ```
185
- */
186
- declare function createI18nContext(locale: string, config?: I18nConfig): I18nContext;
12
+ import 'vue';
187
13
 
188
14
  /**
189
15
  * Define blog configuration helper
@@ -214,4 +40,4 @@ declare function getAstroConfig(options?: {
214
40
  };
215
41
  };
216
42
 
217
- export { type AlternateLink, type BlogConfig, FooterConfig, I18N_CONFIG_KEY, I18N_LOCALE_KEY, I18N_TRANSLATIONS_KEY, I18nConfig, type I18nContext, Locale, type MergedLocaleConfig, NavigationItem, SidebarConfig, SiteConfig, SocialLink, UITranslations, type UseI18nReturn, createI18nContext, defineBlogConfig, formatDate, formatDateShort, getAlternateLinks, getAstroConfig, getLocaleByCode, getLocaleConfig, getLocaleFromPath, getLocalePrefix, getLocalizedPath, getTextDirection, isMultiLanguageEnabled, isRTL, removeLocalePrefix, t, useI18n };
43
+ export { type BlogConfig, FooterConfig, I18nConfig, SidebarConfig, SiteConfig, SocialLink, defineBlogConfig, getAstroConfig };
package/dist/index.js CHANGED
@@ -1,27 +1,53 @@
1
1
  import {
2
- defaultFooterConfig,
3
2
  defaultIcons,
3
+ defaultSocialLinks,
4
+ defineSocialLinks,
5
+ socialLinks
6
+ } from "./chunk-PG43JO4O.js";
7
+ import "./chunk-FXPGR372.js";
8
+ import {
9
+ filterPostsByLocale,
10
+ formatDate,
11
+ formatDateShort,
12
+ getAlternateLinks,
13
+ getContentPathPrefix,
14
+ getLocaleByCode,
15
+ getLocaleConfig,
16
+ getLocaleFromPath,
17
+ getLocalePrefix,
18
+ getLocalizedPath,
19
+ getTextDirection,
20
+ isMultiLanguageEnabled,
21
+ isRTL,
22
+ removeLocalePrefix,
23
+ t
24
+ } from "./chunk-Z3O3JK56.js";
25
+ import {
26
+ defaultFooterConfig,
4
27
  defaultMenu,
5
28
  defaultSEO,
6
29
  defaultSidebarConfig,
7
30
  defaultSiteConfig,
8
- defaultSocialLinks,
9
31
  defineFooterConfig,
10
32
  defineMenu,
11
33
  defineSidebarConfig,
12
34
  defineSiteConfig,
13
- defineSocialLinks,
14
35
  footerConfig,
15
36
  menu,
16
37
  sidebarConfig,
17
- siteConfig,
18
- socialLinks
19
- } from "./chunk-AZHCNNAC.js";
20
- import "./chunk-FXPGR372.js";
38
+ siteConfig
39
+ } from "./chunk-DAH2XP4W.js";
40
+ import {
41
+ I18N_CONFIG_KEY,
42
+ I18N_LOCALE_KEY,
43
+ I18N_TRANSLATIONS_KEY,
44
+ createI18nContext,
45
+ useI18n
46
+ } from "./chunk-PZICDGJG.js";
21
47
  import {
22
48
  astroBlogIntegration,
23
49
  integration_default
24
- } from "./chunk-HVQKQN6B.js";
50
+ } from "./chunk-6D3XRDNY.js";
25
51
  import {
26
52
  builtInTranslations,
27
53
  defaultI18nConfig,
@@ -30,208 +56,7 @@ import {
30
56
  enTranslations,
31
57
  getUITranslations,
32
58
  zhCNTranslations
33
- } from "./chunk-ATRISB7B.js";
34
-
35
- // src/utils/i18n.ts
36
- function getLocaleFromPath(pathname, config = defaultI18nConfig) {
37
- const segments = pathname.replace(/^\//, "").split("/");
38
- const firstSegment = segments[0];
39
- const matchedLocale = config.locales.find(
40
- (locale) => locale.code === firstSegment
41
- );
42
- if (matchedLocale) {
43
- return matchedLocale.code;
44
- }
45
- return config.defaultLocale;
46
- }
47
- function getLocaleByCode(code, config = defaultI18nConfig) {
48
- return config.locales.find((locale) => locale.code === code);
49
- }
50
- function removeLocalePrefix(pathname, config = defaultI18nConfig) {
51
- const locale = getLocaleFromPath(pathname, config);
52
- if (locale === config.defaultLocale && !config.routing.prefixDefaultLocale) {
53
- return pathname;
54
- }
55
- const prefix = `/${locale}`;
56
- if (pathname.startsWith(prefix)) {
57
- const rest = pathname.slice(prefix.length);
58
- return rest || "/";
59
- }
60
- return pathname;
61
- }
62
- function getLocalizedPath(pathname, targetLocale, config = defaultI18nConfig) {
63
- const basePath = removeLocalePrefix(pathname, config);
64
- if (targetLocale === config.defaultLocale && !config.routing.prefixDefaultLocale) {
65
- return basePath;
66
- }
67
- if (basePath === "/") {
68
- return `/${targetLocale}`;
69
- }
70
- return `/${targetLocale}${basePath}`;
71
- }
72
- function getAlternateLinks(pathname, baseUrl, config = defaultI18nConfig) {
73
- const links = [];
74
- for (const locale of config.locales) {
75
- const localizedPath = getLocalizedPath(pathname, locale.code, config);
76
- links.push({
77
- locale: locale.code,
78
- url: `${baseUrl.replace(/\/$/, "")}${localizedPath}`,
79
- hreflang: locale.htmlLang
80
- });
81
- }
82
- const defaultPath = getLocalizedPath(
83
- pathname,
84
- config.defaultLocale,
85
- config
86
- );
87
- links.push({
88
- locale: "x-default",
89
- url: `${baseUrl.replace(/\/$/, "")}${defaultPath}`,
90
- hreflang: "x-default"
91
- });
92
- return links;
93
- }
94
- function deepMerge(base, override) {
95
- const result = { ...base };
96
- for (const key in override) {
97
- if (Object.prototype.hasOwnProperty.call(override, key)) {
98
- const overrideValue = override[key];
99
- const baseValue = base[key];
100
- if (typeof overrideValue === "object" && overrideValue !== null && !Array.isArray(overrideValue) && typeof baseValue === "object" && baseValue !== null && !Array.isArray(baseValue)) {
101
- result[key] = deepMerge(baseValue, overrideValue);
102
- } else if (overrideValue !== void 0) {
103
- result[key] = overrideValue;
104
- }
105
- }
106
- }
107
- return result;
108
- }
109
- function getLocaleConfig(locale, config = defaultI18nConfig) {
110
- const localeData = getLocaleByCode(locale, config);
111
- const localeOverrides = config.localeConfigs[locale] || {};
112
- const localeInfo = localeData || {
113
- code: locale,
114
- name: locale,
115
- htmlLang: locale,
116
- dateLocale: locale,
117
- direction: "ltr"
118
- };
119
- const site = deepMerge(defaultSiteConfig, localeOverrides.site || {});
120
- const menu2 = localeOverrides.menu || defaultMenu;
121
- const footer = deepMerge(defaultFooterConfig, localeOverrides.footer || {});
122
- const sidebar = localeOverrides.sidebar ? {
123
- ...sidebarConfig,
124
- ...localeOverrides.sidebar,
125
- // Use locale-specific groups if provided, otherwise keep default
126
- groups: localeOverrides.sidebar.groups || sidebarConfig.groups
127
- } : sidebarConfig;
128
- const ui = getUITranslations(locale, config);
129
- return {
130
- locale: localeInfo,
131
- site,
132
- menu: menu2,
133
- footer,
134
- sidebar,
135
- ui
136
- };
137
- }
138
- function t(key, locale, config) {
139
- const translations = getUITranslations(locale, config);
140
- return translations[key] || key;
141
- }
142
- function formatDate(date, locale, options) {
143
- const dateObj = typeof date === "string" ? new Date(date) : date;
144
- const defaultOptions = {
145
- year: "numeric",
146
- month: "long",
147
- day: "numeric"
148
- };
149
- return new Intl.DateTimeFormat(locale, options || defaultOptions).format(
150
- dateObj
151
- );
152
- }
153
- function formatDateShort(date, locale) {
154
- const dateObj = typeof date === "string" ? new Date(date) : date;
155
- return new Intl.DateTimeFormat(locale, {
156
- year: "numeric",
157
- month: "numeric",
158
- day: "numeric"
159
- }).format(dateObj);
160
- }
161
- function isRTL(locale, config = defaultI18nConfig) {
162
- const localeData = getLocaleByCode(locale, config);
163
- return localeData?.direction === "rtl";
164
- }
165
- function getTextDirection(locale, config = defaultI18nConfig) {
166
- return isRTL(locale, config) ? "rtl" : "ltr";
167
- }
168
- function isMultiLanguageEnabled(config = defaultI18nConfig) {
169
- return config.locales.length > 1;
170
- }
171
- function getLocalePrefix(locale, config = defaultI18nConfig) {
172
- if (locale === config.defaultLocale && !config.routing.prefixDefaultLocale) {
173
- return "";
174
- }
175
- return `/${locale}`;
176
- }
177
-
178
- // src/utils/useI18n.ts
179
- import { inject, computed } from "vue";
180
- var I18N_LOCALE_KEY = /* @__PURE__ */ Symbol("i18n-locale");
181
- var I18N_CONFIG_KEY = /* @__PURE__ */ Symbol("i18n-config");
182
- var I18N_TRANSLATIONS_KEY = /* @__PURE__ */ Symbol("i18n-translations");
183
- function useI18n() {
184
- const injectedLocale = inject(I18N_LOCALE_KEY, "zh-CN");
185
- const injectedTranslations = inject(
186
- I18N_TRANSLATIONS_KEY,
187
- void 0
188
- );
189
- const injectedConfig = inject(I18N_CONFIG_KEY, void 0);
190
- const locale = computed(() => injectedLocale);
191
- const translations = computed(() => {
192
- if (injectedTranslations) {
193
- return injectedTranslations;
194
- }
195
- return getUITranslations(injectedLocale, injectedConfig);
196
- });
197
- function t2(key) {
198
- return translations.value[key] || key;
199
- }
200
- function formatDate2(date, options) {
201
- const dateObj = typeof date === "string" ? new Date(date) : date;
202
- const defaultOptions = {
203
- year: "numeric",
204
- month: "long",
205
- day: "numeric"
206
- };
207
- return new Intl.DateTimeFormat(
208
- locale.value,
209
- options || defaultOptions
210
- ).format(dateObj);
211
- }
212
- function formatDateShort2(date) {
213
- const dateObj = typeof date === "string" ? new Date(date) : date;
214
- return new Intl.DateTimeFormat(locale.value, {
215
- year: "numeric",
216
- month: "numeric",
217
- day: "numeric"
218
- }).format(dateObj);
219
- }
220
- return {
221
- locale,
222
- t: t2,
223
- formatDate: formatDate2,
224
- formatDateShort: formatDateShort2,
225
- translations
226
- };
227
- }
228
- function createI18nContext(locale, config) {
229
- return {
230
- locale,
231
- translations: getUITranslations(locale, config),
232
- config
233
- };
234
- }
59
+ } from "./chunk-A2E2VSAQ.js";
235
60
 
236
61
  // src/index.ts
237
62
  function defineBlogConfig(config) {
@@ -275,11 +100,13 @@ export {
275
100
  defineSiteConfig,
276
101
  defineSocialLinks,
277
102
  enTranslations,
103
+ filterPostsByLocale,
278
104
  footerConfig,
279
105
  formatDate,
280
106
  formatDateShort,
281
107
  getAlternateLinks,
282
108
  getAstroConfig,
109
+ getContentPathPrefix,
283
110
  getLocaleByCode,
284
111
  getLocaleConfig,
285
112
  getLocaleFromPath,
@@ -1,7 +1,7 @@
1
1
  import { AstroIntegration } from 'astro';
2
- import { I as I18nConfig } from './i18n-5H4W145i.js';
2
+ import { I as I18nConfig } from './i18n-DYYPTq4o.js';
3
3
  import './types/index.js';
4
- import './sidebar-Da-W_4Lr.js';
4
+ import './sidebar-DNdiCKBw.js';
5
5
 
6
6
  /**
7
7
  * @jet-w/astro-blog Integration
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  astroBlogIntegration,
3
3
  integration_default
4
- } from "./chunk-HVQKQN6B.js";
5
- import "./chunk-ATRISB7B.js";
4
+ } from "./chunk-6D3XRDNY.js";
5
+ import "./chunk-A2E2VSAQ.js";
6
6
  export {
7
7
  astroBlogIntegration,
8
8
  integration_default as default
@@ -89,4 +89,4 @@ declare const sidebarConfig: SidebarConfig;
89
89
  declare function defineSidebarConfig(config: Partial<SidebarConfig>): SidebarConfig;
90
90
  declare const defaultSidebarConfig: SidebarConfig;
91
91
 
92
- export { type DividerConfig as D, type ManualConfig as M, type PathMatchConfig as P, type SidebarItem as S, type SidebarGroup as a, type SidebarConfig as b, defineSidebarConfig as c, defaultSidebarConfig as d, type ScanConfig as e, type MixedConfig as f, sidebarConfig as s };
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 };