@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.
- package/dist/{chunk-HVQKQN6B.js → chunk-6D3XRDNY.js} +1 -1
- package/dist/{chunk-ATRISB7B.js → chunk-A2E2VSAQ.js} +43 -3
- package/dist/chunk-DAH2XP4W.js +154 -0
- package/dist/{chunk-AZHCNNAC.js → chunk-PG43JO4O.js} +1 -153
- package/dist/chunk-PZICDGJG.js +69 -0
- package/dist/chunk-Z3O3JK56.js +186 -0
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +9 -7
- package/dist/{i18n-5H4W145i.d.ts → i18n-DYYPTq4o.d.ts} +21 -1
- package/dist/index.d.ts +10 -184
- package/dist/index.js +37 -210
- package/dist/integration.d.ts +2 -2
- package/dist/integration.js +2 -2
- package/dist/{sidebar-Da-W_4Lr.d.ts → sidebar-DNdiCKBw.d.ts} +1 -1
- package/dist/utils/i18n.d.ts +133 -0
- package/dist/utils/i18n.js +49 -0
- package/dist/utils/sidebar.d.ts +1 -1
- package/dist/utils/useI18n.d.ts +74 -0
- package/dist/utils/useI18n.js +15 -0
- package/package.json +9 -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/Header.astro +9 -5
- package/src/components/layout/Sidebar.astro +14 -11
- package/src/components/ui/SearchBox.vue +13 -5
- package/src/components/ui/SearchInterface.vue +49 -25
- 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/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 +13 -4
- package/templates/default/content/posts/blog_docs_en/{get-started → 01.get-started}/01-intro.md +1 -1
- package/templates/default/content/posts/blog_docs_en/{get-started → 01.get-started}/02-install.md +1 -1
- package/templates/default/content/posts/blog_docs_en/{get-started → 01.get-started}/03-create-post.md +1 -1
- package/templates/default/content/posts/blog_docs_en/{get-started → 01.get-started}/04-structure.md +1 -1
- package/templates/default/content/posts/blog_docs_en/01.get-started/05-deploy.md +208 -0
- package/templates/default/content/posts/blog_docs_en/{get-started → 01.get-started}/README.md +1 -1
- package/templates/default/content/posts/blog_docs_en/02.guide/02-containers.md +245 -0
- package/templates/default/content/posts/blog_docs_en/{guide/markdown → 02.guide}/03-code-blocks.md +2 -1
- package/templates/default/content/posts/blog_docs_en/{guide/features/01-mermaid.md → 02.guide/03-mermaid.md} +1 -1
- package/templates/default/content/posts/blog_docs_en/{guide/features → 02.guide}/04-icons.md +4 -2
- package/templates/default/content/posts/blog_docs_en/{guide/features/02-latex.md → 02.guide/06-latex.md} +1 -1
- package/templates/default/content/posts/blog_docs_en/{guide/features/03-video.md → 02.guide/07-video.md} +1 -1
- package/templates/default/content/posts/blog_docs_en/02.guide/08-slides.md +359 -0
- package/templates/default/content/posts/blog_docs_en/{guide/markdown → 02.guide}/README.md +22 -3
- package/templates/default/content/posts/blog_docs_en/{config → 03.config}/01-site.md +1 -1
- package/templates/default/content/posts/blog_docs_en/{config → 03.config}/02-sidebar.md +1 -1
- package/templates/default/content/posts/blog_docs_en/{config → 03.config}/03-i18n.md +88 -24
- package/templates/default/content/posts/blog_docs_en/{config → 03.config}/README.md +1 -1
- package/templates/default/content/posts/blog_docs_en/README.md +2 -1
- 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.dev.json +31 -0
- package/templates/default/package.json +1 -1
- package/templates/default/src/config/locales/en/index.ts +5 -1
- package/templates/default/src/config/locales/en/menu.ts +3 -1
- package/templates/default/src/config/locales/en/sidebar.ts +18 -2
- package/templates/default/src/config/locales/en/site.ts +1 -1
- package/templates/default/src/config/locales/en/ui.ts +29 -0
- package/templates/default/src/config/locales/zh-CN/index.ts +5 -1
- package/templates/default/src/config/locales/zh-CN/menu.ts +7 -5
- package/templates/default/src/config/locales/zh-CN/sidebar.ts +22 -6
- package/templates/default/src/config/locales/zh-CN/site.ts +2 -2
- package/templates/default/src/config/locales/zh-CN/ui.ts +29 -0
- package/templates/default/src/config/site.ts +2 -2
- package/templates/default/src/content.config.ts +15 -3
- 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-i18n.md +0 -355
- package/templates/default/content/posts/blog_docs/12-slides.mdx +0 -552
- package/templates/default/content/posts/blog_docs/README.md +0 -152
- package/templates/default/content/posts/blog_docs_en/get-started/05-deploy.md +0 -197
- package/templates/default/content/posts/blog_docs_en/guide/README.md +0 -59
- package/templates/default/content/posts/blog_docs_en/guide/features/README.md +0 -51
- package/templates/default/content/posts/blog_docs_en/guide/markdown/02-containers.md +0 -226
|
@@ -35,6 +35,20 @@ var zhCNTranslations = {
|
|
|
35
35
|
searchResults: "\u641C\u7D22\u7ED3\u679C",
|
|
36
36
|
noResults: "\u6CA1\u6709\u627E\u5230\u76F8\u5173\u7ED3\u679C",
|
|
37
37
|
searching: "\u641C\u7D22\u4E2D...",
|
|
38
|
+
searchArticles: "\u641C\u7D22\u6587\u7AE0",
|
|
39
|
+
searchInAllArticles: "\u5728\u6240\u6709\u6587\u7AE0\u4E2D\u67E5\u627E\u60A8\u611F\u5174\u8DA3\u7684\u5185\u5BB9",
|
|
40
|
+
searchTips: "\u641C\u7D22\u6280\u5DE7",
|
|
41
|
+
basicSearch: "\u57FA\u7840\u641C\u7D22",
|
|
42
|
+
advancedFeatures: "\u9AD8\u7EA7\u529F\u80FD",
|
|
43
|
+
searchTipKeyword: "\u8F93\u5165\u5173\u952E\u8BCD\u641C\u7D22\u6807\u9898\u548C\u5185\u5BB9",
|
|
44
|
+
searchTipMixedLang: "\u652F\u6301\u4E2D\u82F1\u6587\u6DF7\u5408\u641C\u7D22",
|
|
45
|
+
searchTipCaseInsensitive: "\u81EA\u52A8\u5FFD\u7565\u5927\u5C0F\u5199",
|
|
46
|
+
searchTipRealtime: "\u5B9E\u65F6\u641C\u7D22\u5EFA\u8BAE",
|
|
47
|
+
searchTipFilter: "\u6309\u6807\u7B7E\u548C\u5206\u7C7B\u7B5B\u9009",
|
|
48
|
+
searchTipFuzzy: "\u652F\u6301\u6A21\u7CCA\u5339\u914D",
|
|
49
|
+
// Hero section
|
|
50
|
+
browsePosts: "\u6D4F\u89C8\u6587\u7AE0",
|
|
51
|
+
aboutMe: "\u5173\u4E8E\u6211",
|
|
38
52
|
// Pagination
|
|
39
53
|
previousPage: "\u4E0A\u4E00\u9875",
|
|
40
54
|
nextPage: "\u4E0B\u4E00\u9875",
|
|
@@ -44,7 +58,8 @@ var zhCNTranslations = {
|
|
|
44
58
|
publishedOn: "\u53D1\u5E03\u4E8E",
|
|
45
59
|
updatedOn: "\u66F4\u65B0\u4E8E",
|
|
46
60
|
author: "\u4F5C\u8005",
|
|
47
|
-
tableOfContents: "\u76EE\u5F55",
|
|
61
|
+
tableOfContents: "\u9875\u9762\u76EE\u5F55",
|
|
62
|
+
readingProgress: "\u9605\u8BFB\u8FDB\u5EA6",
|
|
48
63
|
relatedPosts: "\u76F8\u5173\u6587\u7AE0",
|
|
49
64
|
sharePost: "\u5206\u4EAB\u6587\u7AE0",
|
|
50
65
|
previousPost: "\u4E0A\u4E00\u7BC7",
|
|
@@ -73,7 +88,12 @@ var zhCNTranslations = {
|
|
|
73
88
|
slides: "\u6F14\u793A",
|
|
74
89
|
slidesList: "\u6F14\u793A\u5217\u8868",
|
|
75
90
|
// RSS
|
|
76
|
-
rssFeed: "RSS \u8BA2\u9605"
|
|
91
|
+
rssFeed: "RSS \u8BA2\u9605",
|
|
92
|
+
// Quick Navigation
|
|
93
|
+
quickNavigation: "\u5FEB\u901F\u5BFC\u822A",
|
|
94
|
+
timeline: "\u65F6\u95F4\u8F74",
|
|
95
|
+
viewAllTimeline: "\u67E5\u770B\u5168\u90E8\u65F6\u95F4\u8F74",
|
|
96
|
+
postsCount: "\u7BC7"
|
|
77
97
|
};
|
|
78
98
|
var enTranslations = {
|
|
79
99
|
// Navigation
|
|
@@ -111,6 +131,20 @@ var enTranslations = {
|
|
|
111
131
|
searchResults: "Search Results",
|
|
112
132
|
noResults: "No results found",
|
|
113
133
|
searching: "Searching...",
|
|
134
|
+
searchArticles: "Search Articles",
|
|
135
|
+
searchInAllArticles: "Find content that interests you in all articles",
|
|
136
|
+
searchTips: "Search Tips",
|
|
137
|
+
basicSearch: "Basic Search",
|
|
138
|
+
advancedFeatures: "Advanced Features",
|
|
139
|
+
searchTipKeyword: "Enter keywords to search titles and content",
|
|
140
|
+
searchTipMixedLang: "Supports mixed language search",
|
|
141
|
+
searchTipCaseInsensitive: "Case insensitive",
|
|
142
|
+
searchTipRealtime: "Real-time search suggestions",
|
|
143
|
+
searchTipFilter: "Filter by tags and categories",
|
|
144
|
+
searchTipFuzzy: "Supports fuzzy matching",
|
|
145
|
+
// Hero section
|
|
146
|
+
browsePosts: "Browse Posts",
|
|
147
|
+
aboutMe: "About Me",
|
|
114
148
|
// Pagination
|
|
115
149
|
previousPage: "Previous",
|
|
116
150
|
nextPage: "Next",
|
|
@@ -121,6 +155,7 @@ var enTranslations = {
|
|
|
121
155
|
updatedOn: "Updated on",
|
|
122
156
|
author: "Author",
|
|
123
157
|
tableOfContents: "Table of Contents",
|
|
158
|
+
readingProgress: "Reading Progress",
|
|
124
159
|
relatedPosts: "Related Posts",
|
|
125
160
|
sharePost: "Share",
|
|
126
161
|
previousPost: "Previous",
|
|
@@ -149,7 +184,12 @@ var enTranslations = {
|
|
|
149
184
|
slides: "Slides",
|
|
150
185
|
slidesList: "All Slides",
|
|
151
186
|
// RSS
|
|
152
|
-
rssFeed: "RSS Feed"
|
|
187
|
+
rssFeed: "RSS Feed",
|
|
188
|
+
// Quick Navigation
|
|
189
|
+
quickNavigation: "Quick Navigation",
|
|
190
|
+
timeline: "Timeline",
|
|
191
|
+
viewAllTimeline: "View all timeline",
|
|
192
|
+
postsCount: "posts"
|
|
153
193
|
};
|
|
154
194
|
var builtInTranslations = {
|
|
155
195
|
"zh-CN": zhCNTranslations,
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// src/config/site.ts
|
|
2
|
+
var siteConfig = {
|
|
3
|
+
title: "My Astro Blog",
|
|
4
|
+
description: "",
|
|
5
|
+
author: "Author",
|
|
6
|
+
email: "",
|
|
7
|
+
avatar: "/images/avatar.svg",
|
|
8
|
+
social: {
|
|
9
|
+
github: "",
|
|
10
|
+
twitter: "",
|
|
11
|
+
linkedin: "",
|
|
12
|
+
email: ""
|
|
13
|
+
},
|
|
14
|
+
menu: [
|
|
15
|
+
{
|
|
16
|
+
name: "\u9996\u9875",
|
|
17
|
+
href: "/",
|
|
18
|
+
icon: "home"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "\u535A\u5BA2",
|
|
22
|
+
href: "/posts",
|
|
23
|
+
icon: "posts"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "\u5173\u4E8E",
|
|
27
|
+
href: "/about",
|
|
28
|
+
icon: "about"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
};
|
|
32
|
+
var defaultSEO = {
|
|
33
|
+
title: siteConfig.title,
|
|
34
|
+
description: siteConfig.description,
|
|
35
|
+
image: "/images/og-image.jpg",
|
|
36
|
+
type: "website"
|
|
37
|
+
};
|
|
38
|
+
function defineSiteConfig(config) {
|
|
39
|
+
return {
|
|
40
|
+
...siteConfig,
|
|
41
|
+
...config,
|
|
42
|
+
social: {
|
|
43
|
+
...siteConfig.social,
|
|
44
|
+
...config.social
|
|
45
|
+
},
|
|
46
|
+
menu: config.menu || siteConfig.menu
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
var defaultSiteConfig = siteConfig;
|
|
50
|
+
|
|
51
|
+
// src/config/menu.ts
|
|
52
|
+
var menu = [
|
|
53
|
+
{
|
|
54
|
+
name: "\u9996\u9875",
|
|
55
|
+
href: "/",
|
|
56
|
+
icon: "home"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "\u535A\u5BA2",
|
|
60
|
+
href: "/posts",
|
|
61
|
+
icon: "posts"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "\u5173\u4E8E",
|
|
65
|
+
href: "/about",
|
|
66
|
+
icon: "about"
|
|
67
|
+
}
|
|
68
|
+
];
|
|
69
|
+
function defineMenu(items) {
|
|
70
|
+
return items;
|
|
71
|
+
}
|
|
72
|
+
var defaultMenu = menu;
|
|
73
|
+
|
|
74
|
+
// src/config/sidebar.ts
|
|
75
|
+
var sidebarConfig = {
|
|
76
|
+
enabled: true,
|
|
77
|
+
width: "280px",
|
|
78
|
+
position: "right",
|
|
79
|
+
showSearch: true,
|
|
80
|
+
showRecentPosts: true,
|
|
81
|
+
recentPostsCount: 5,
|
|
82
|
+
showPopularTags: true,
|
|
83
|
+
popularTagsCount: 8,
|
|
84
|
+
showArchives: true,
|
|
85
|
+
archivesCount: 6,
|
|
86
|
+
showFriendLinks: true,
|
|
87
|
+
friendLinks: [
|
|
88
|
+
{ title: "Astro \u5B98\u7F51", url: "https://astro.build" },
|
|
89
|
+
{ title: "Tailwind CSS", url: "https://tailwindcss.com" },
|
|
90
|
+
{ title: "Vue.js", url: "https://vuejs.org" }
|
|
91
|
+
],
|
|
92
|
+
groups: [
|
|
93
|
+
{
|
|
94
|
+
type: "scan",
|
|
95
|
+
title: "\u6587\u6863\u76EE\u5F55",
|
|
96
|
+
icon: "folder",
|
|
97
|
+
scanPath: "",
|
|
98
|
+
collapsed: false
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
};
|
|
102
|
+
function defineSidebarConfig(config) {
|
|
103
|
+
return {
|
|
104
|
+
...sidebarConfig,
|
|
105
|
+
...config,
|
|
106
|
+
groups: config.groups || sidebarConfig.groups
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
var defaultSidebarConfig = sidebarConfig;
|
|
110
|
+
|
|
111
|
+
// src/config/footer.ts
|
|
112
|
+
var footerConfig = {
|
|
113
|
+
quickLinksTitle: "\u5FEB\u901F\u94FE\u63A5",
|
|
114
|
+
quickLinks: [
|
|
115
|
+
{ name: "\u9996\u9875", href: "/" },
|
|
116
|
+
{ name: "\u6587\u7AE0", href: "/posts" },
|
|
117
|
+
{ name: "\u6807\u7B7E", href: "/tags" },
|
|
118
|
+
{ name: "\u5206\u7C7B", href: "/categories" },
|
|
119
|
+
{ name: "\u5F52\u6863", href: "/archives" },
|
|
120
|
+
{ name: "\u5173\u4E8E", href: "/about" }
|
|
121
|
+
],
|
|
122
|
+
contactTitle: "\u8054\u7CFB\u65B9\u5F0F",
|
|
123
|
+
socialLinks: [],
|
|
124
|
+
showRss: true,
|
|
125
|
+
rssUrl: "/rss.xml",
|
|
126
|
+
copyright: "\xA9 {year} {author}. All rights reserved.",
|
|
127
|
+
poweredBy: {
|
|
128
|
+
text: "Astro",
|
|
129
|
+
url: "https://astro.build"
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
function defineFooterConfig(config) {
|
|
133
|
+
return {
|
|
134
|
+
...footerConfig,
|
|
135
|
+
...config
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
var defaultFooterConfig = footerConfig;
|
|
139
|
+
|
|
140
|
+
export {
|
|
141
|
+
siteConfig,
|
|
142
|
+
defaultSEO,
|
|
143
|
+
defineSiteConfig,
|
|
144
|
+
defaultSiteConfig,
|
|
145
|
+
menu,
|
|
146
|
+
defineMenu,
|
|
147
|
+
defaultMenu,
|
|
148
|
+
sidebarConfig,
|
|
149
|
+
defineSidebarConfig,
|
|
150
|
+
defaultSidebarConfig,
|
|
151
|
+
footerConfig,
|
|
152
|
+
defineFooterConfig,
|
|
153
|
+
defaultFooterConfig
|
|
154
|
+
};
|
|
@@ -1,113 +1,3 @@
|
|
|
1
|
-
// src/config/site.ts
|
|
2
|
-
var siteConfig = {
|
|
3
|
-
title: "My Astro Blog",
|
|
4
|
-
description: "A modern blog built with Astro, Vue, and Tailwind CSS",
|
|
5
|
-
author: "Author",
|
|
6
|
-
email: "",
|
|
7
|
-
avatar: "/images/avatar.svg",
|
|
8
|
-
social: {
|
|
9
|
-
github: "",
|
|
10
|
-
twitter: "",
|
|
11
|
-
linkedin: "",
|
|
12
|
-
email: ""
|
|
13
|
-
},
|
|
14
|
-
menu: [
|
|
15
|
-
{
|
|
16
|
-
name: "\u9996\u9875",
|
|
17
|
-
href: "/",
|
|
18
|
-
icon: "home"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
name: "\u535A\u5BA2",
|
|
22
|
-
href: "/posts",
|
|
23
|
-
icon: "posts"
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: "\u5173\u4E8E",
|
|
27
|
-
href: "/about",
|
|
28
|
-
icon: "about"
|
|
29
|
-
}
|
|
30
|
-
]
|
|
31
|
-
};
|
|
32
|
-
var defaultSEO = {
|
|
33
|
-
title: siteConfig.title,
|
|
34
|
-
description: siteConfig.description,
|
|
35
|
-
image: "/images/og-image.jpg",
|
|
36
|
-
type: "website"
|
|
37
|
-
};
|
|
38
|
-
function defineSiteConfig(config) {
|
|
39
|
-
return {
|
|
40
|
-
...siteConfig,
|
|
41
|
-
...config,
|
|
42
|
-
social: {
|
|
43
|
-
...siteConfig.social,
|
|
44
|
-
...config.social
|
|
45
|
-
},
|
|
46
|
-
menu: config.menu || siteConfig.menu
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
var defaultSiteConfig = siteConfig;
|
|
50
|
-
|
|
51
|
-
// src/config/menu.ts
|
|
52
|
-
var menu = [
|
|
53
|
-
{
|
|
54
|
-
name: "\u9996\u9875",
|
|
55
|
-
href: "/",
|
|
56
|
-
icon: "home"
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
name: "\u535A\u5BA2",
|
|
60
|
-
href: "/posts",
|
|
61
|
-
icon: "posts"
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: "\u5173\u4E8E",
|
|
65
|
-
href: "/about",
|
|
66
|
-
icon: "about"
|
|
67
|
-
}
|
|
68
|
-
];
|
|
69
|
-
function defineMenu(items) {
|
|
70
|
-
return items;
|
|
71
|
-
}
|
|
72
|
-
var defaultMenu = menu;
|
|
73
|
-
|
|
74
|
-
// src/config/sidebar.ts
|
|
75
|
-
var sidebarConfig = {
|
|
76
|
-
enabled: true,
|
|
77
|
-
width: "280px",
|
|
78
|
-
position: "right",
|
|
79
|
-
showSearch: true,
|
|
80
|
-
showRecentPosts: true,
|
|
81
|
-
recentPostsCount: 5,
|
|
82
|
-
showPopularTags: true,
|
|
83
|
-
popularTagsCount: 8,
|
|
84
|
-
showArchives: true,
|
|
85
|
-
archivesCount: 6,
|
|
86
|
-
showFriendLinks: true,
|
|
87
|
-
friendLinks: [
|
|
88
|
-
{ title: "Astro \u5B98\u7F51", url: "https://astro.build" },
|
|
89
|
-
{ title: "Tailwind CSS", url: "https://tailwindcss.com" },
|
|
90
|
-
{ title: "Vue.js", url: "https://vuejs.org" }
|
|
91
|
-
],
|
|
92
|
-
groups: [
|
|
93
|
-
{
|
|
94
|
-
type: "scan",
|
|
95
|
-
title: "\u6587\u6863\u76EE\u5F55",
|
|
96
|
-
icon: "folder",
|
|
97
|
-
scanPath: "",
|
|
98
|
-
collapsed: false
|
|
99
|
-
}
|
|
100
|
-
]
|
|
101
|
-
};
|
|
102
|
-
function defineSidebarConfig(config) {
|
|
103
|
-
return {
|
|
104
|
-
...sidebarConfig,
|
|
105
|
-
...config,
|
|
106
|
-
groups: config.groups || sidebarConfig.groups
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
var defaultSidebarConfig = sidebarConfig;
|
|
110
|
-
|
|
111
1
|
// src/config/social.ts
|
|
112
2
|
var defaultIcons = {
|
|
113
3
|
github: "M12 0C5.374 0 0 5.373 0 12c0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23A11.509 11.509 0 0112 5.803c1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576C20.566 21.797 24 17.3 24 12c0-6.627-5.373-12-12-12z",
|
|
@@ -123,51 +13,9 @@ function defineSocialLinks(links) {
|
|
|
123
13
|
return links;
|
|
124
14
|
}
|
|
125
15
|
|
|
126
|
-
// src/config/footer.ts
|
|
127
|
-
var footerConfig = {
|
|
128
|
-
quickLinksTitle: "\u5FEB\u901F\u94FE\u63A5",
|
|
129
|
-
quickLinks: [
|
|
130
|
-
{ name: "\u9996\u9875", href: "/" },
|
|
131
|
-
{ name: "\u6587\u7AE0", href: "/posts" },
|
|
132
|
-
{ name: "\u6807\u7B7E", href: "/tags" },
|
|
133
|
-
{ name: "\u5206\u7C7B", href: "/categories" },
|
|
134
|
-
{ name: "\u5F52\u6863", href: "/archives" },
|
|
135
|
-
{ name: "\u5173\u4E8E", href: "/about" }
|
|
136
|
-
],
|
|
137
|
-
contactTitle: "\u8054\u7CFB\u65B9\u5F0F",
|
|
138
|
-
socialLinks: [],
|
|
139
|
-
showRss: true,
|
|
140
|
-
rssUrl: "/rss.xml",
|
|
141
|
-
copyright: "\xA9 {year} {author}. All rights reserved.",
|
|
142
|
-
poweredBy: {
|
|
143
|
-
text: "Astro",
|
|
144
|
-
url: "https://astro.build"
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
function defineFooterConfig(config) {
|
|
148
|
-
return {
|
|
149
|
-
...footerConfig,
|
|
150
|
-
...config
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
var defaultFooterConfig = footerConfig;
|
|
154
|
-
|
|
155
16
|
export {
|
|
156
|
-
siteConfig,
|
|
157
|
-
defaultSEO,
|
|
158
|
-
defineSiteConfig,
|
|
159
|
-
defaultSiteConfig,
|
|
160
|
-
menu,
|
|
161
|
-
defineMenu,
|
|
162
|
-
defaultMenu,
|
|
163
|
-
sidebarConfig,
|
|
164
|
-
defineSidebarConfig,
|
|
165
|
-
defaultSidebarConfig,
|
|
166
17
|
defaultIcons,
|
|
167
18
|
socialLinks,
|
|
168
19
|
defaultSocialLinks,
|
|
169
|
-
defineSocialLinks
|
|
170
|
-
footerConfig,
|
|
171
|
-
defineFooterConfig,
|
|
172
|
-
defaultFooterConfig
|
|
20
|
+
defineSocialLinks
|
|
173
21
|
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getUITranslations
|
|
3
|
+
} from "./chunk-A2E2VSAQ.js";
|
|
4
|
+
|
|
5
|
+
// src/utils/useI18n.ts
|
|
6
|
+
import { inject, computed } from "vue";
|
|
7
|
+
var I18N_LOCALE_KEY = /* @__PURE__ */ Symbol("i18n-locale");
|
|
8
|
+
var I18N_CONFIG_KEY = /* @__PURE__ */ Symbol("i18n-config");
|
|
9
|
+
var I18N_TRANSLATIONS_KEY = /* @__PURE__ */ Symbol("i18n-translations");
|
|
10
|
+
function useI18n() {
|
|
11
|
+
const injectedLocale = inject(I18N_LOCALE_KEY, "zh-CN");
|
|
12
|
+
const injectedTranslations = inject(
|
|
13
|
+
I18N_TRANSLATIONS_KEY,
|
|
14
|
+
void 0
|
|
15
|
+
);
|
|
16
|
+
const injectedConfig = inject(I18N_CONFIG_KEY, void 0);
|
|
17
|
+
const locale = computed(() => injectedLocale);
|
|
18
|
+
const translations = computed(() => {
|
|
19
|
+
if (injectedTranslations) {
|
|
20
|
+
return injectedTranslations;
|
|
21
|
+
}
|
|
22
|
+
return getUITranslations(injectedLocale, injectedConfig);
|
|
23
|
+
});
|
|
24
|
+
function t(key) {
|
|
25
|
+
return translations.value[key] || key;
|
|
26
|
+
}
|
|
27
|
+
function formatDate(date, options) {
|
|
28
|
+
const dateObj = typeof date === "string" ? new Date(date) : date;
|
|
29
|
+
const defaultOptions = {
|
|
30
|
+
year: "numeric",
|
|
31
|
+
month: "long",
|
|
32
|
+
day: "numeric"
|
|
33
|
+
};
|
|
34
|
+
return new Intl.DateTimeFormat(
|
|
35
|
+
locale.value,
|
|
36
|
+
options || defaultOptions
|
|
37
|
+
).format(dateObj);
|
|
38
|
+
}
|
|
39
|
+
function formatDateShort(date) {
|
|
40
|
+
const dateObj = typeof date === "string" ? new Date(date) : date;
|
|
41
|
+
return new Intl.DateTimeFormat(locale.value, {
|
|
42
|
+
year: "numeric",
|
|
43
|
+
month: "numeric",
|
|
44
|
+
day: "numeric"
|
|
45
|
+
}).format(dateObj);
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
locale,
|
|
49
|
+
t,
|
|
50
|
+
formatDate,
|
|
51
|
+
formatDateShort,
|
|
52
|
+
translations
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function createI18nContext(locale, config) {
|
|
56
|
+
return {
|
|
57
|
+
locale,
|
|
58
|
+
translations: getUITranslations(locale, config),
|
|
59
|
+
config
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export {
|
|
64
|
+
I18N_LOCALE_KEY,
|
|
65
|
+
I18N_CONFIG_KEY,
|
|
66
|
+
I18N_TRANSLATIONS_KEY,
|
|
67
|
+
useI18n,
|
|
68
|
+
createI18nContext
|
|
69
|
+
};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defaultFooterConfig,
|
|
3
|
+
defaultMenu,
|
|
4
|
+
defaultSiteConfig,
|
|
5
|
+
sidebarConfig
|
|
6
|
+
} from "./chunk-DAH2XP4W.js";
|
|
7
|
+
import {
|
|
8
|
+
defaultI18nConfig,
|
|
9
|
+
getUITranslations
|
|
10
|
+
} from "./chunk-A2E2VSAQ.js";
|
|
11
|
+
|
|
12
|
+
// src/utils/i18n.ts
|
|
13
|
+
function getLocaleFromPath(pathname, config = defaultI18nConfig) {
|
|
14
|
+
const segments = pathname.replace(/^\//, "").split("/");
|
|
15
|
+
const firstSegment = segments[0];
|
|
16
|
+
const matchedLocale = config.locales.find(
|
|
17
|
+
(locale) => locale.code === firstSegment
|
|
18
|
+
);
|
|
19
|
+
if (matchedLocale) {
|
|
20
|
+
return matchedLocale.code;
|
|
21
|
+
}
|
|
22
|
+
return config.defaultLocale;
|
|
23
|
+
}
|
|
24
|
+
function getLocaleByCode(code, config = defaultI18nConfig) {
|
|
25
|
+
return config.locales.find((locale) => locale.code === code);
|
|
26
|
+
}
|
|
27
|
+
function removeLocalePrefix(pathname, config = defaultI18nConfig) {
|
|
28
|
+
const locale = getLocaleFromPath(pathname, config);
|
|
29
|
+
if (locale === config.defaultLocale && !config.routing.prefixDefaultLocale) {
|
|
30
|
+
return pathname;
|
|
31
|
+
}
|
|
32
|
+
const prefix = `/${locale}`;
|
|
33
|
+
if (pathname.startsWith(prefix)) {
|
|
34
|
+
const rest = pathname.slice(prefix.length);
|
|
35
|
+
return rest || "/";
|
|
36
|
+
}
|
|
37
|
+
return pathname;
|
|
38
|
+
}
|
|
39
|
+
function getLocalizedPath(pathname, targetLocale, config = defaultI18nConfig) {
|
|
40
|
+
const basePath = removeLocalePrefix(pathname, config);
|
|
41
|
+
if (targetLocale === config.defaultLocale && !config.routing.prefixDefaultLocale) {
|
|
42
|
+
return basePath;
|
|
43
|
+
}
|
|
44
|
+
if (basePath === "/") {
|
|
45
|
+
return `/${targetLocale}`;
|
|
46
|
+
}
|
|
47
|
+
return `/${targetLocale}${basePath}`;
|
|
48
|
+
}
|
|
49
|
+
function getAlternateLinks(pathname, baseUrl, config = defaultI18nConfig) {
|
|
50
|
+
const links = [];
|
|
51
|
+
for (const locale of config.locales) {
|
|
52
|
+
const localizedPath = getLocalizedPath(pathname, locale.code, config);
|
|
53
|
+
links.push({
|
|
54
|
+
locale: locale.code,
|
|
55
|
+
url: `${baseUrl.replace(/\/$/, "")}${localizedPath}`,
|
|
56
|
+
hreflang: locale.htmlLang
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const defaultPath = getLocalizedPath(
|
|
60
|
+
pathname,
|
|
61
|
+
config.defaultLocale,
|
|
62
|
+
config
|
|
63
|
+
);
|
|
64
|
+
links.push({
|
|
65
|
+
locale: "x-default",
|
|
66
|
+
url: `${baseUrl.replace(/\/$/, "")}${defaultPath}`,
|
|
67
|
+
hreflang: "x-default"
|
|
68
|
+
});
|
|
69
|
+
return links;
|
|
70
|
+
}
|
|
71
|
+
function deepMerge(base, override) {
|
|
72
|
+
const result = { ...base };
|
|
73
|
+
for (const key in override) {
|
|
74
|
+
if (Object.prototype.hasOwnProperty.call(override, key)) {
|
|
75
|
+
const overrideValue = override[key];
|
|
76
|
+
const baseValue = base[key];
|
|
77
|
+
if (typeof overrideValue === "object" && overrideValue !== null && !Array.isArray(overrideValue) && typeof baseValue === "object" && baseValue !== null && !Array.isArray(baseValue)) {
|
|
78
|
+
result[key] = deepMerge(baseValue, overrideValue);
|
|
79
|
+
} else if (overrideValue !== void 0) {
|
|
80
|
+
result[key] = overrideValue;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
function getLocaleConfig(locale, config = defaultI18nConfig) {
|
|
87
|
+
const localeData = getLocaleByCode(locale, config);
|
|
88
|
+
const localeOverrides = config.localeConfigs[locale] || {};
|
|
89
|
+
const localeInfo = localeData || {
|
|
90
|
+
code: locale,
|
|
91
|
+
name: locale,
|
|
92
|
+
htmlLang: locale,
|
|
93
|
+
dateLocale: locale,
|
|
94
|
+
direction: "ltr"
|
|
95
|
+
};
|
|
96
|
+
const site = deepMerge(defaultSiteConfig, localeOverrides.site || {});
|
|
97
|
+
const menu = localeOverrides.menu || defaultMenu;
|
|
98
|
+
const footer = deepMerge(defaultFooterConfig, localeOverrides.footer || {});
|
|
99
|
+
const sidebar = localeOverrides.sidebar ? {
|
|
100
|
+
...sidebarConfig,
|
|
101
|
+
...localeOverrides.sidebar,
|
|
102
|
+
// Use locale-specific groups if provided, otherwise keep default
|
|
103
|
+
groups: localeOverrides.sidebar.groups || sidebarConfig.groups
|
|
104
|
+
} : sidebarConfig;
|
|
105
|
+
const ui = getUITranslations(locale, config);
|
|
106
|
+
return {
|
|
107
|
+
locale: localeInfo,
|
|
108
|
+
site,
|
|
109
|
+
menu,
|
|
110
|
+
footer,
|
|
111
|
+
sidebar,
|
|
112
|
+
ui
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function t(key, locale, config) {
|
|
116
|
+
const translations = getUITranslations(locale, config);
|
|
117
|
+
return translations[key] || key;
|
|
118
|
+
}
|
|
119
|
+
function formatDate(date, locale, options) {
|
|
120
|
+
const dateObj = typeof date === "string" ? new Date(date) : date;
|
|
121
|
+
const defaultOptions = {
|
|
122
|
+
year: "numeric",
|
|
123
|
+
month: "long",
|
|
124
|
+
day: "numeric"
|
|
125
|
+
};
|
|
126
|
+
return new Intl.DateTimeFormat(locale, options || defaultOptions).format(
|
|
127
|
+
dateObj
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
function formatDateShort(date, locale) {
|
|
131
|
+
const dateObj = typeof date === "string" ? new Date(date) : date;
|
|
132
|
+
return new Intl.DateTimeFormat(locale, {
|
|
133
|
+
year: "numeric",
|
|
134
|
+
month: "numeric",
|
|
135
|
+
day: "numeric"
|
|
136
|
+
}).format(dateObj);
|
|
137
|
+
}
|
|
138
|
+
function isRTL(locale, config = defaultI18nConfig) {
|
|
139
|
+
const localeData = getLocaleByCode(locale, config);
|
|
140
|
+
return localeData?.direction === "rtl";
|
|
141
|
+
}
|
|
142
|
+
function getTextDirection(locale, config = defaultI18nConfig) {
|
|
143
|
+
return isRTL(locale, config) ? "rtl" : "ltr";
|
|
144
|
+
}
|
|
145
|
+
function isMultiLanguageEnabled(config = defaultI18nConfig) {
|
|
146
|
+
return config.locales.length > 1;
|
|
147
|
+
}
|
|
148
|
+
function getLocalePrefix(locale, config = defaultI18nConfig) {
|
|
149
|
+
if (locale === config.defaultLocale && !config.routing.prefixDefaultLocale) {
|
|
150
|
+
return "";
|
|
151
|
+
}
|
|
152
|
+
return `/${locale}`;
|
|
153
|
+
}
|
|
154
|
+
function getContentPathPrefix(locale, config = defaultI18nConfig) {
|
|
155
|
+
const localeConfig = config.localeConfigs[locale];
|
|
156
|
+
return localeConfig?.contentPathPrefix;
|
|
157
|
+
}
|
|
158
|
+
function filterPostsByLocale(posts, locale, config = defaultI18nConfig) {
|
|
159
|
+
const contentPathPrefix = getContentPathPrefix(locale, config);
|
|
160
|
+
if (!contentPathPrefix) {
|
|
161
|
+
return posts;
|
|
162
|
+
}
|
|
163
|
+
return posts.filter((post) => {
|
|
164
|
+
const postPath = post.id.toLowerCase();
|
|
165
|
+
const prefix = contentPathPrefix.toLowerCase();
|
|
166
|
+
return postPath.startsWith(prefix + "/") || postPath === prefix;
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export {
|
|
171
|
+
getLocaleFromPath,
|
|
172
|
+
getLocaleByCode,
|
|
173
|
+
removeLocalePrefix,
|
|
174
|
+
getLocalizedPath,
|
|
175
|
+
getAlternateLinks,
|
|
176
|
+
getLocaleConfig,
|
|
177
|
+
t,
|
|
178
|
+
formatDate,
|
|
179
|
+
formatDateShort,
|
|
180
|
+
isRTL,
|
|
181
|
+
getTextDirection,
|
|
182
|
+
isMultiLanguageEnabled,
|
|
183
|
+
getLocalePrefix,
|
|
184
|
+
getContentPathPrefix,
|
|
185
|
+
filterPostsByLocale
|
|
186
|
+
};
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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,
|
|
3
|
-
export { F as FooterConfig, m as FooterLink, I as I18nConfig, o as I18nRoutingConfig, L as Locale, n as LocaleConfig, S as SocialLink, 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-
|
|
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';
|
|
3
|
+
export { F as FooterConfig, m as FooterLink, I as I18nConfig, o as I18nRoutingConfig, L as Locale, n as LocaleConfig, S as SocialLink, 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';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Default site configuration
|