@jet-w/astro-blog 0.1.6 → 0.2.1
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-6D3XRDNY.js +145 -0
- package/dist/chunk-A2E2VSAQ.js +246 -0
- package/dist/{chunk-GYLSY3OJ.js → chunk-TJTPX2WP.js} +1 -1
- package/dist/config/index.d.ts +3 -47
- package/dist/config/index.js +18 -2
- package/dist/i18n-PgMCFBw0.d.ts +222 -0
- package/dist/index.d.ts +204 -7
- package/dist/index.js +255 -3
- package/dist/integration.d.ts +9 -1
- package/dist/integration.js +2 -1
- package/dist/{sidebar-DNdiCKBw.d.ts → sidebar-Da-W_4Lr.d.ts} +1 -1
- package/dist/utils/sidebar.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/blog/FloatingToc.vue +11 -3
- package/src/components/blog/Hero.astro +17 -2
- package/src/components/blog/NavigationTabs.vue +46 -15
- package/src/components/blog/PostCard.astro +28 -10
- package/src/components/blog/RelatedPosts.astro +23 -7
- package/src/components/blog/TableOfContents.astro +10 -4
- package/src/components/blog/TagCloud.astro +4 -3
- package/src/components/home/FeaturedPostsSection.astro +22 -6
- package/src/components/home/QuickNavSection.astro +33 -4
- package/src/components/home/RecentPostsSection.astro +22 -6
- package/src/components/home/StatsSection.astro +24 -6
- package/src/components/layout/Footer.astro +36 -20
- package/src/components/layout/Header.astro +75 -17
- package/src/components/layout/Sidebar.astro +40 -25
- package/src/components/ui/LanguageSwitcher.vue +183 -0
- package/src/components/ui/SearchBox.vue +13 -5
- package/src/components/ui/SearchInterface.vue +49 -25
- package/src/layouts/BaseLayout.astro +77 -52
- package/src/layouts/PageLayout.astro +22 -27
- package/src/layouts/SlidesLayout.astro +14 -2
- package/src/pages/archives/[year]/[month].astro +36 -17
- package/src/pages/archives/index.astro +36 -20
- package/src/pages/categories/[category].astro +33 -16
- package/src/pages/categories/index.astro +37 -14
- package/src/pages/posts/[...slug].astro +125 -18
- package/src/pages/posts/index.astro +59 -37
- package/src/pages/posts/page/[page].astro +65 -27
- package/src/pages/rss.xml.ts +18 -6
- package/src/pages/search.astro +50 -14
- package/src/pages/slides/index.astro +25 -6
- package/src/pages/tags/[tag].astro +32 -15
- package/src/pages/tags/index.astro +39 -16
- package/src/plugins/remark-containers.mjs +351 -322
- package/src/plugins/remark-protect-code.mjs +69 -0
- package/src/styles/global.css +35 -1
- package/templates/default/.claude/ralph-loop.local.md +48 -0
- package/templates/default/astro.config.mjs +33 -4
- package/templates/default/content/posts/blog_docs_en/01.get-started/01-intro.md +81 -0
- package/templates/default/content/posts/blog_docs_en/01.get-started/02-install.md +137 -0
- package/templates/default/content/posts/blog_docs_en/01.get-started/03-create-post.md +176 -0
- package/templates/default/content/posts/blog_docs_en/01.get-started/04-structure.md +173 -0
- package/templates/default/content/posts/blog_docs_en/01.get-started/05-deploy.md +208 -0
- package/templates/default/content/posts/blog_docs_en/01.get-started/README.md +52 -0
- package/templates/default/content/posts/blog_docs_en/02.guide/02-containers.md +245 -0
- package/templates/default/content/posts/blog_docs_en/02.guide/03-code-blocks.md +207 -0
- package/templates/default/content/posts/blog_docs_en/02.guide/03-mermaid.md +194 -0
- package/templates/default/content/posts/blog_docs_en/02.guide/04-icons.md +229 -0
- package/templates/default/content/posts/blog_docs_en/02.guide/06-latex.md +233 -0
- package/templates/default/content/posts/blog_docs_en/02.guide/07-video.md +184 -0
- package/templates/default/content/posts/blog_docs_en/02.guide/08-slides.md +359 -0
- package/templates/default/content/posts/blog_docs_en/02.guide/README.md +213 -0
- package/templates/default/content/posts/blog_docs_en/03.config/01-site.md +208 -0
- package/templates/default/content/posts/blog_docs_en/03.config/02-sidebar.md +240 -0
- package/templates/default/content/posts/blog_docs_en/03.config/03-i18n.md +349 -0
- package/templates/default/content/posts/blog_docs_en/03.config/README.md +85 -0
- package/templates/default/content/posts/blog_docs_en/README.md +79 -0
- package/templates/default/content/posts/blog_docs_zh/01.get-started/01-intro.md +81 -0
- package/templates/default/content/posts/blog_docs_zh/01.get-started/02-install.md +137 -0
- package/templates/default/content/posts/blog_docs_zh/01.get-started/03-create-post.md +176 -0
- package/templates/default/content/posts/blog_docs_zh/01.get-started/04-structure.md +173 -0
- package/templates/default/content/posts/blog_docs_zh/01.get-started/05-deploy.md +208 -0
- package/templates/default/content/posts/blog_docs_zh/01.get-started/README.md +52 -0
- package/templates/default/content/posts/blog_docs_zh/02.guide/02-containers.md +245 -0
- package/templates/default/content/posts/blog_docs_zh/02.guide/03-code-blocks.md +206 -0
- package/templates/default/content/posts/blog_docs_zh/02.guide/03-mermaid.md +194 -0
- package/templates/default/content/posts/blog_docs_zh/02.guide/04-icons.md +229 -0
- package/templates/default/content/posts/blog_docs_zh/02.guide/06-latex.md +233 -0
- package/templates/default/content/posts/blog_docs_zh/02.guide/07-video.md +184 -0
- package/templates/default/content/posts/blog_docs_zh/02.guide/08-slides.md +359 -0
- package/templates/default/content/posts/blog_docs_zh/02.guide/README.md +213 -0
- package/templates/default/content/posts/blog_docs_zh/03.config/01-site.md +208 -0
- package/templates/default/content/posts/blog_docs_zh/03.config/02-sidebar.md +240 -0
- package/templates/default/content/posts/blog_docs_zh/03.config/03-i18n.md +348 -0
- package/templates/default/content/posts/blog_docs_zh/03.config/README.md +85 -0
- package/templates/default/content/posts/blog_docs_zh/README.md +78 -0
- package/templates/default/package-lock.json +9667 -0
- package/templates/default/package.json +1 -1
- package/templates/default/src/config/footer.ts +14 -11
- package/templates/default/src/config/locales/en/footer.ts +17 -0
- package/templates/default/src/config/locales/en/index.ts +20 -0
- package/templates/default/src/config/locales/en/menu.ts +14 -0
- package/templates/default/src/config/locales/en/sidebar.ts +34 -0
- package/templates/default/src/config/locales/en/site.ts +7 -0
- package/templates/default/src/config/locales/en/ui.ts +29 -0
- package/templates/default/src/config/locales/index.ts +7 -0
- package/templates/default/src/config/locales/zh-CN/footer.ts +17 -0
- package/templates/default/src/config/locales/zh-CN/index.ts +20 -0
- package/templates/default/src/config/locales/zh-CN/menu.ts +14 -0
- package/templates/default/src/config/locales/zh-CN/sidebar.ts +34 -0
- package/templates/default/src/config/locales/zh-CN/site.ts +7 -0
- package/templates/default/src/config/locales/zh-CN/ui.ts +29 -0
- package/templates/default/src/config/sidebar.ts +10 -12
- package/templates/default/src/config/site.ts +2 -2
- package/templates/default/src/content.config.ts +15 -3
- package/templates/default/src/env.d.ts +7 -0
- package/dist/chunk-MQXPSOYB.js +0 -124
- package/templates/default/content/posts/blog_docs/01-quick-start.md +0 -162
- package/templates/default/content/posts/blog_docs/02-frontmatter.md +0 -277
- package/templates/default/content/posts/blog_docs/03-markdown-basic.md +0 -350
- package/templates/default/content/posts/blog_docs/04-containers.md +0 -331
- package/templates/default/content/posts/blog_docs/05-code-blocks.md +0 -388
- package/templates/default/content/posts/blog_docs/06-mermaid.md +0 -431
- package/templates/default/content/posts/blog_docs/07-video.md +0 -243
- package/templates/default/content/posts/blog_docs/08-latex.md +0 -382
- package/templates/default/content/posts/blog_docs/09-icons.md +0 -326
- package/templates/default/content/posts/blog_docs/10-sidebar.md +0 -445
- package/templates/default/content/posts/blog_docs/11-config.md +0 -334
- package/templates/default/content/posts/blog_docs/12-slides.mdx +0 -552
- package/templates/default/content/posts/blog_docs/README.md +0 -151
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { SiteConfig, NavigationItem } from './types/index.js';
|
|
2
|
+
import { b as SidebarConfig } from './sidebar-Da-W_4Lr.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 社交链接配置
|
|
6
|
+
*/
|
|
7
|
+
interface SocialLink {
|
|
8
|
+
type: string;
|
|
9
|
+
url: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
icon?: string;
|
|
12
|
+
}
|
|
13
|
+
declare const defaultIcons: Record<string, string>;
|
|
14
|
+
declare const socialLinks: SocialLink[];
|
|
15
|
+
declare const defaultSocialLinks: SocialLink[];
|
|
16
|
+
/**
|
|
17
|
+
* Define social links
|
|
18
|
+
*/
|
|
19
|
+
declare function defineSocialLinks(links: SocialLink[]): SocialLink[];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Footer 配置
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
interface FooterLink {
|
|
26
|
+
name: string;
|
|
27
|
+
href: string;
|
|
28
|
+
}
|
|
29
|
+
interface FooterConfig {
|
|
30
|
+
quickLinksTitle: string;
|
|
31
|
+
quickLinks: FooterLink[];
|
|
32
|
+
contactTitle: string;
|
|
33
|
+
socialLinks: SocialLink[];
|
|
34
|
+
showRss: boolean;
|
|
35
|
+
rssUrl: string;
|
|
36
|
+
copyright: string;
|
|
37
|
+
poweredBy: {
|
|
38
|
+
text: string;
|
|
39
|
+
url: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
declare const footerConfig: FooterConfig;
|
|
43
|
+
/**
|
|
44
|
+
* Define footer configuration
|
|
45
|
+
*/
|
|
46
|
+
declare function defineFooterConfig(config: Partial<FooterConfig>): FooterConfig;
|
|
47
|
+
declare const defaultFooterConfig: FooterConfig;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* i18n Configuration Module
|
|
51
|
+
*
|
|
52
|
+
* Provides multi-language support configuration for the blog.
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Locale definition
|
|
57
|
+
*/
|
|
58
|
+
interface Locale {
|
|
59
|
+
/** Language code (e.g., 'en', 'zh-CN', 'ja') */
|
|
60
|
+
code: string;
|
|
61
|
+
/** Display name (e.g., 'English', '中文') */
|
|
62
|
+
name: string;
|
|
63
|
+
/** HTML lang attribute value */
|
|
64
|
+
htmlLang: string;
|
|
65
|
+
/** Locale for Intl.DateTimeFormat */
|
|
66
|
+
dateLocale: string;
|
|
67
|
+
/** Text direction */
|
|
68
|
+
direction?: 'ltr' | 'rtl';
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* UI translation strings
|
|
72
|
+
*/
|
|
73
|
+
interface UITranslations {
|
|
74
|
+
home: string;
|
|
75
|
+
blog: string;
|
|
76
|
+
about: string;
|
|
77
|
+
search: string;
|
|
78
|
+
posts: string;
|
|
79
|
+
postList: string;
|
|
80
|
+
noPostsFound: string;
|
|
81
|
+
readMore: string;
|
|
82
|
+
readingTime: string;
|
|
83
|
+
minuteRead: string;
|
|
84
|
+
tags: string;
|
|
85
|
+
categories: string;
|
|
86
|
+
allTags: string;
|
|
87
|
+
allCategories: string;
|
|
88
|
+
taggedWith: string;
|
|
89
|
+
inCategory: string;
|
|
90
|
+
archives: string;
|
|
91
|
+
postsInArchive: string;
|
|
92
|
+
recentPosts: string;
|
|
93
|
+
popularTags: string;
|
|
94
|
+
friendLinks: string;
|
|
95
|
+
documentTree: string;
|
|
96
|
+
quickLinks: string;
|
|
97
|
+
contact: string;
|
|
98
|
+
searchPlaceholder: string;
|
|
99
|
+
searchResults: string;
|
|
100
|
+
noResults: string;
|
|
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;
|
|
115
|
+
previousPage: string;
|
|
116
|
+
nextPage: string;
|
|
117
|
+
page: string;
|
|
118
|
+
of: string;
|
|
119
|
+
publishedOn: string;
|
|
120
|
+
updatedOn: string;
|
|
121
|
+
author: string;
|
|
122
|
+
tableOfContents: string;
|
|
123
|
+
readingProgress: string;
|
|
124
|
+
relatedPosts: string;
|
|
125
|
+
sharePost: string;
|
|
126
|
+
previousPost: string;
|
|
127
|
+
nextPost: string;
|
|
128
|
+
backToTop: string;
|
|
129
|
+
copyCode: string;
|
|
130
|
+
copied: string;
|
|
131
|
+
expand: string;
|
|
132
|
+
collapse: string;
|
|
133
|
+
expandCode: string;
|
|
134
|
+
collapseCode: string;
|
|
135
|
+
lines: string;
|
|
136
|
+
viewMode: string;
|
|
137
|
+
cardView: string;
|
|
138
|
+
listView: string;
|
|
139
|
+
sortBy: string;
|
|
140
|
+
sortByDate: string;
|
|
141
|
+
sortByTitle: string;
|
|
142
|
+
filterByTag: string;
|
|
143
|
+
filterByCategory: string;
|
|
144
|
+
clearFilter: string;
|
|
145
|
+
allPosts: string;
|
|
146
|
+
draft: string;
|
|
147
|
+
slides: string;
|
|
148
|
+
slidesList: string;
|
|
149
|
+
rssFeed: string;
|
|
150
|
+
quickNavigation: string;
|
|
151
|
+
timeline: string;
|
|
152
|
+
viewAllTimeline: string;
|
|
153
|
+
postsCount: string;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Locale-specific configuration
|
|
157
|
+
*/
|
|
158
|
+
interface LocaleConfig {
|
|
159
|
+
/** Site configuration overrides */
|
|
160
|
+
site?: Partial<SiteConfig>;
|
|
161
|
+
/** Navigation menu items */
|
|
162
|
+
menu?: NavigationItem[];
|
|
163
|
+
/** Footer configuration overrides */
|
|
164
|
+
footer?: Partial<FooterConfig>;
|
|
165
|
+
/** Sidebar configuration overrides */
|
|
166
|
+
sidebar?: Partial<SidebarConfig>;
|
|
167
|
+
/** UI translation overrides */
|
|
168
|
+
ui?: Partial<UITranslations>;
|
|
169
|
+
/** Content path prefix for filtering posts by locale (e.g., 'blog_docs_en' for English) */
|
|
170
|
+
contentPathPrefix?: string;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* i18n routing configuration
|
|
174
|
+
*/
|
|
175
|
+
interface I18nRoutingConfig {
|
|
176
|
+
/** Whether to add prefix for default locale (e.g., /zh-CN/posts vs /posts) */
|
|
177
|
+
prefixDefaultLocale: boolean;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Complete i18n configuration
|
|
181
|
+
*/
|
|
182
|
+
interface I18nConfig {
|
|
183
|
+
/** Default locale code */
|
|
184
|
+
defaultLocale: string;
|
|
185
|
+
/** Available locales */
|
|
186
|
+
locales: Locale[];
|
|
187
|
+
/** Locale-specific configurations */
|
|
188
|
+
localeConfigs: Record<string, LocaleConfig>;
|
|
189
|
+
/** Routing configuration */
|
|
190
|
+
routing: I18nRoutingConfig;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Default Chinese (Simplified) UI translations
|
|
194
|
+
*/
|
|
195
|
+
declare const zhCNTranslations: UITranslations;
|
|
196
|
+
/**
|
|
197
|
+
* Default English UI translations
|
|
198
|
+
*/
|
|
199
|
+
declare const enTranslations: UITranslations;
|
|
200
|
+
/**
|
|
201
|
+
* Built-in translations for common languages
|
|
202
|
+
*/
|
|
203
|
+
declare const builtInTranslations: Record<string, UITranslations>;
|
|
204
|
+
/**
|
|
205
|
+
* Default locales
|
|
206
|
+
*/
|
|
207
|
+
declare const defaultLocales: Locale[];
|
|
208
|
+
/**
|
|
209
|
+
* Default i18n configuration (Chinese only, backward compatible)
|
|
210
|
+
*/
|
|
211
|
+
declare const defaultI18nConfig: I18nConfig;
|
|
212
|
+
/**
|
|
213
|
+
* Helper function to define i18n configuration with type safety
|
|
214
|
+
*/
|
|
215
|
+
declare function defineI18nConfig(config: Partial<I18nConfig>): I18nConfig;
|
|
216
|
+
/**
|
|
217
|
+
* Get UI translations for a specific locale
|
|
218
|
+
* Falls back to built-in translations, then to English
|
|
219
|
+
*/
|
|
220
|
+
declare function getUITranslations(locale: string, config?: I18nConfig): UITranslations;
|
|
221
|
+
|
|
222
|
+
export { type FooterConfig as F, type I18nConfig as I, type Locale as L, type SocialLink as S, type UITranslations as U, defaultSocialLinks as a, defineSocialLinks as b, defaultFooterConfig as c, defaultIcons as d, defineFooterConfig as e, footerConfig as f, defaultI18nConfig as g, defineI18nConfig as h, getUITranslations as i, builtInTranslations as j, enTranslations as k, defaultLocales as l, type FooterLink as m, type LocaleConfig as n, type I18nRoutingConfig as o, socialLinks as s, zhCNTranslations as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,208 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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-PgMCFBw0.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-PgMCFBw0.js';
|
|
6
|
+
import { SiteConfig, NavigationItem } from './types/index.js';
|
|
7
|
+
export { BlogPost, Category, PostFrontmatter, SEOProps, SearchResult, Tag } from './types/index.js';
|
|
7
8
|
export { AstroBlogIntegrationOptions, default as astroBlog, default as astroBlogIntegration } from './integration.js';
|
|
9
|
+
import { ComputedRef } from 'vue';
|
|
8
10
|
import 'astro';
|
|
9
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
|
+
* Get content path prefix for a specific locale
|
|
122
|
+
* Returns the contentPathPrefix from locale config, or undefined if not set
|
|
123
|
+
*/
|
|
124
|
+
declare function getContentPathPrefix(locale: string, config?: I18nConfig): string | undefined;
|
|
125
|
+
/**
|
|
126
|
+
* Filter posts by locale based on contentPathPrefix
|
|
127
|
+
* If contentPathPrefix is set, only return posts that start with that prefix
|
|
128
|
+
* If not set, return all posts (backward compatible)
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* // If en locale has contentPathPrefix: 'blog_docs_en'
|
|
132
|
+
* filterPostsByLocale(posts, 'en', config)
|
|
133
|
+
* // Returns only posts with id starting with 'blog_docs_en/'
|
|
134
|
+
*/
|
|
135
|
+
declare function filterPostsByLocale<T extends {
|
|
136
|
+
id: string;
|
|
137
|
+
}>(posts: T[], locale: string, config?: I18nConfig): T[];
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Vue Composable for i18n
|
|
141
|
+
*
|
|
142
|
+
* Provides i18n support for Vue components in the blog.
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* i18n injection keys
|
|
147
|
+
*/
|
|
148
|
+
declare const I18N_LOCALE_KEY: unique symbol;
|
|
149
|
+
declare const I18N_CONFIG_KEY: unique symbol;
|
|
150
|
+
declare const I18N_TRANSLATIONS_KEY: unique symbol;
|
|
151
|
+
/**
|
|
152
|
+
* i18n context provided to Vue components
|
|
153
|
+
*/
|
|
154
|
+
interface I18nContext {
|
|
155
|
+
locale: string;
|
|
156
|
+
translations: UITranslations;
|
|
157
|
+
config?: I18nConfig;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Return type of useI18n composable
|
|
161
|
+
*/
|
|
162
|
+
interface UseI18nReturn {
|
|
163
|
+
/** Current locale code */
|
|
164
|
+
locale: ComputedRef<string>;
|
|
165
|
+
/** Translation function */
|
|
166
|
+
t: (key: keyof UITranslations) => string;
|
|
167
|
+
/** Format date according to locale */
|
|
168
|
+
formatDate: (date: Date | string, options?: Intl.DateTimeFormatOptions) => string;
|
|
169
|
+
/** Format date in short format */
|
|
170
|
+
formatDateShort: (date: Date | string) => string;
|
|
171
|
+
/** All translations for current locale */
|
|
172
|
+
translations: ComputedRef<UITranslations>;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Vue composable for i18n support
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```vue
|
|
179
|
+
* <script setup>
|
|
180
|
+
* import { useI18n } from '@jet-w/astro-blog/utils/useI18n';
|
|
181
|
+
*
|
|
182
|
+
* const { t, formatDate, locale } = useI18n();
|
|
183
|
+
* </script>
|
|
184
|
+
*
|
|
185
|
+
* <template>
|
|
186
|
+
* <h1>{{ t('postList') }}</h1>
|
|
187
|
+
* <span>{{ formatDate(post.pubDate) }}</span>
|
|
188
|
+
* </template>
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
declare function useI18n(): UseI18nReturn;
|
|
192
|
+
/**
|
|
193
|
+
* Create i18n context for providing to Vue components
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```astro
|
|
197
|
+
* ---
|
|
198
|
+
* import { createI18nContext } from '@jet-w/astro-blog/utils/useI18n';
|
|
199
|
+
* const i18nContext = createI18nContext('en', i18nConfig);
|
|
200
|
+
* ---
|
|
201
|
+
* <Component client:load {...i18nContext} />
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
declare function createI18nContext(locale: string, config?: I18nConfig): I18nContext;
|
|
205
|
+
|
|
10
206
|
/**
|
|
11
207
|
* Define blog configuration helper
|
|
12
208
|
*/
|
|
@@ -15,6 +211,7 @@ interface BlogConfig {
|
|
|
15
211
|
sidebar?: SidebarConfig;
|
|
16
212
|
footer?: FooterConfig;
|
|
17
213
|
social?: SocialLink[];
|
|
214
|
+
i18n?: I18nConfig;
|
|
18
215
|
}
|
|
19
216
|
declare function defineBlogConfig(config: BlogConfig): BlogConfig;
|
|
20
217
|
/**
|
|
@@ -35,4 +232,4 @@ declare function getAstroConfig(options?: {
|
|
|
35
232
|
};
|
|
36
233
|
};
|
|
37
234
|
|
|
38
|
-
export { type BlogConfig, FooterConfig, SidebarConfig, SiteConfig, SocialLink, defineBlogConfig, getAstroConfig };
|
|
235
|
+
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, filterPostsByLocale, formatDate, formatDateShort, getAlternateLinks, getAstroConfig, getContentPathPrefix, getLocaleByCode, getLocaleConfig, getLocaleFromPath, getLocalePrefix, getLocalizedPath, getTextDirection, isMultiLanguageEnabled, isRTL, removeLocalePrefix, t, useI18n };
|