@jet-w/astro-blog 0.2.1 → 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-DAH2XP4W.js +154 -0
- package/dist/{chunk-TJTPX2WP.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 +8 -6
- package/dist/{i18n-PgMCFBw0.d.ts → i18n-DYYPTq4o.d.ts} +1 -1
- package/dist/index.d.ts +10 -202
- package/dist/index.js +33 -223
- package/dist/integration.d.ts +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/templates/default/package.dev.json +31 -0
- package/templates/default/package.json +1 -1
|
@@ -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: "",
|
|
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
|
package/dist/config/index.js
CHANGED
|
@@ -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
|
-
|
|
19
|
-
} from "../chunk-TJTPX2WP.js";
|
|
20
|
+
siteConfig
|
|
21
|
+
} from "../chunk-DAH2XP4W.js";
|
|
20
22
|
import {
|
|
21
23
|
builtInTranslations,
|
|
22
24
|
defaultI18nConfig,
|