@jet-w/astro-blog 0.2.1 → 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,49 @@
1
+ import {
2
+ filterPostsByLocale,
3
+ formatDate,
4
+ formatDateShort,
5
+ getAlternateLinks,
6
+ getContentPathPrefix,
7
+ getLocaleByCode,
8
+ getLocaleConfig,
9
+ getLocaleFromPath,
10
+ getLocalePrefix,
11
+ getLocalizedPath,
12
+ getTextDirection,
13
+ isMultiLanguageEnabled,
14
+ isRTL,
15
+ removeLocalePrefix,
16
+ t
17
+ } from "../chunk-Z3O3JK56.js";
18
+ import "../chunk-DAH2XP4W.js";
19
+ import {
20
+ builtInTranslations,
21
+ defaultI18nConfig,
22
+ defineI18nConfig,
23
+ enTranslations,
24
+ getUITranslations,
25
+ zhCNTranslations
26
+ } from "../chunk-A2E2VSAQ.js";
27
+ export {
28
+ builtInTranslations,
29
+ defaultI18nConfig,
30
+ defineI18nConfig,
31
+ enTranslations,
32
+ filterPostsByLocale,
33
+ formatDate,
34
+ formatDateShort,
35
+ getAlternateLinks,
36
+ getContentPathPrefix,
37
+ getLocaleByCode,
38
+ getLocaleConfig,
39
+ getLocaleFromPath,
40
+ getLocalePrefix,
41
+ getLocalizedPath,
42
+ getTextDirection,
43
+ getUITranslations,
44
+ isMultiLanguageEnabled,
45
+ isRTL,
46
+ removeLocalePrefix,
47
+ t,
48
+ zhCNTranslations
49
+ };
@@ -1,4 +1,4 @@
1
- import { S as SidebarItem, a as SidebarGroup, b as SidebarConfig } from '../sidebar-Da-W_4Lr.js';
1
+ import { c as SidebarItem, b as SidebarGroup, S as SidebarConfig } from '../sidebar-DNdiCKBw.js';
2
2
 
3
3
  /**
4
4
  * 侧边栏工具函数
@@ -0,0 +1,74 @@
1
+ import { ComputedRef } from 'vue';
2
+ import { U as UITranslations, I as I18nConfig } from '../i18n-DYYPTq4o.js';
3
+ export { L as Locale } from '../i18n-DYYPTq4o.js';
4
+ import '../types/index.js';
5
+ import '../sidebar-DNdiCKBw.js';
6
+
7
+ /**
8
+ * Vue Composable for i18n
9
+ *
10
+ * Provides i18n support for Vue components in the blog.
11
+ */
12
+
13
+ /**
14
+ * i18n injection keys
15
+ */
16
+ declare const I18N_LOCALE_KEY: unique symbol;
17
+ declare const I18N_CONFIG_KEY: unique symbol;
18
+ declare const I18N_TRANSLATIONS_KEY: unique symbol;
19
+ /**
20
+ * i18n context provided to Vue components
21
+ */
22
+ interface I18nContext {
23
+ locale: string;
24
+ translations: UITranslations;
25
+ config?: I18nConfig;
26
+ }
27
+ /**
28
+ * Return type of useI18n composable
29
+ */
30
+ interface UseI18nReturn {
31
+ /** Current locale code */
32
+ locale: ComputedRef<string>;
33
+ /** Translation function */
34
+ t: (key: keyof UITranslations) => string;
35
+ /** Format date according to locale */
36
+ formatDate: (date: Date | string, options?: Intl.DateTimeFormatOptions) => string;
37
+ /** Format date in short format */
38
+ formatDateShort: (date: Date | string) => string;
39
+ /** All translations for current locale */
40
+ translations: ComputedRef<UITranslations>;
41
+ }
42
+ /**
43
+ * Vue composable for i18n support
44
+ *
45
+ * @example
46
+ * ```vue
47
+ * <script setup>
48
+ * import { useI18n } from '@jet-w/astro-blog/utils/useI18n';
49
+ *
50
+ * const { t, formatDate, locale } = useI18n();
51
+ * </script>
52
+ *
53
+ * <template>
54
+ * <h1>{{ t('postList') }}</h1>
55
+ * <span>{{ formatDate(post.pubDate) }}</span>
56
+ * </template>
57
+ * ```
58
+ */
59
+ declare function useI18n(): UseI18nReturn;
60
+ /**
61
+ * Create i18n context for providing to Vue components
62
+ *
63
+ * @example
64
+ * ```astro
65
+ * ---
66
+ * import { createI18nContext } from '@jet-w/astro-blog/utils/useI18n';
67
+ * const i18nContext = createI18nContext('en', i18nConfig);
68
+ * ---
69
+ * <Component client:load {...i18nContext} />
70
+ * ```
71
+ */
72
+ declare function createI18nContext(locale: string, config?: I18nConfig): I18nContext;
73
+
74
+ export { I18N_CONFIG_KEY, I18N_LOCALE_KEY, I18N_TRANSLATIONS_KEY, I18nConfig, type I18nContext, UITranslations, type UseI18nReturn, createI18nContext, useI18n };
@@ -0,0 +1,15 @@
1
+ import {
2
+ I18N_CONFIG_KEY,
3
+ I18N_LOCALE_KEY,
4
+ I18N_TRANSLATIONS_KEY,
5
+ createI18nContext,
6
+ useI18n
7
+ } from "../chunk-PZICDGJG.js";
8
+ import "../chunk-A2E2VSAQ.js";
9
+ export {
10
+ I18N_CONFIG_KEY,
11
+ I18N_LOCALE_KEY,
12
+ I18N_TRANSLATIONS_KEY,
13
+ createI18nContext,
14
+ useI18n
15
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jet-w/astro-blog",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "A modern Astro blog theme with Vue and Tailwind CSS support",
5
5
  "type": "module",
6
6
  "exports": {
@@ -24,6 +24,14 @@
24
24
  "./utils/sidebar": {
25
25
  "types": "./dist/utils/sidebar.d.ts",
26
26
  "import": "./dist/utils/sidebar.js"
27
+ },
28
+ "./utils/i18n": {
29
+ "types": "./dist/utils/i18n.d.ts",
30
+ "import": "./dist/utils/i18n.js"
31
+ },
32
+ "./utils/useI18n": {
33
+ "types": "./dist/utils/useI18n.d.ts",
34
+ "import": "./dist/utils/useI18n.js"
27
35
  }
28
36
  },
29
37
  "files": [
@@ -33,6 +41,9 @@
33
41
  "src/components",
34
42
  "src/layouts",
35
43
  "src/pages",
44
+ "src/types",
45
+ "src/utils",
46
+ "src/config",
36
47
  "templates"
37
48
  ],
38
49
  "scripts": {
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Footer 配置
3
+ */
4
+
5
+ import type { SocialLink } from './social';
6
+
7
+ export interface FooterLink {
8
+ name: string;
9
+ href: string;
10
+ }
11
+
12
+ export interface FooterConfig {
13
+ quickLinksTitle: string;
14
+ quickLinks: FooterLink[];
15
+ contactTitle: string;
16
+ socialLinks: SocialLink[];
17
+ showRss: boolean;
18
+ rssUrl: string;
19
+ copyright: string;
20
+ poweredBy: {
21
+ text: string;
22
+ url: string;
23
+ };
24
+ }
25
+
26
+ export const footerConfig: FooterConfig = {
27
+ quickLinksTitle: '快速链接',
28
+ quickLinks: [
29
+ { name: '首页', href: '/' },
30
+ { name: '文章', href: '/posts' },
31
+ { name: '标签', href: '/tags' },
32
+ { name: '分类', href: '/categories' },
33
+ { name: '归档', href: '/archives' },
34
+ { name: '关于', href: '/about' }
35
+ ],
36
+ contactTitle: '联系方式',
37
+ socialLinks: [],
38
+ showRss: true,
39
+ rssUrl: '/rss.xml',
40
+ copyright: '© {year} {author}. All rights reserved.',
41
+ poweredBy: {
42
+ text: 'Astro',
43
+ url: 'https://astro.build'
44
+ }
45
+ };
46
+
47
+ /**
48
+ * Define footer configuration
49
+ */
50
+ export function defineFooterConfig(config: Partial<FooterConfig>): FooterConfig {
51
+ return {
52
+ ...footerConfig,
53
+ ...config
54
+ };
55
+ }
56
+
57
+ // 向后兼容
58
+ export const defaultFooterConfig = footerConfig;