nuxt-i18n-micro 1.86.0 → 1.87.0
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/client/200.html +2 -2
- package/dist/client/404.html +2 -2
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/8378fa7a-5fb5-44d9-986d-f34c5db00a22.json +1 -0
- package/dist/client/index.html +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +3 -1
- package/dist/runtime/composables/useLocaleHead.js +25 -9
- package/dist/runtime/server/routes/get.js +1 -1
- package/package.json +5 -4
- package/dist/client/_nuxt/builds/meta/9b03c3ea-26a1-4619-b39e-b42f797680ba.json +0 -1
package/dist/client/200.html
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BBbCCCx2.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.BRj5A2lo.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CfVvufsh.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/MjlAM4Ld.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"
|
|
11
|
+
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/MjlAM4Ld.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1746387320983,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"8378fa7a-5fb5-44d9-986d-f34c5db00a22",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/client/404.html
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BBbCCCx2.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.BRj5A2lo.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CfVvufsh.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/MjlAM4Ld.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"
|
|
11
|
+
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/MjlAM4Ld.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1746387320984,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"8378fa7a-5fb5-44d9-986d-f34c5db00a22",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"8378fa7a-5fb5-44d9-986d-f34c5db00a22","timestamp":1746387315515}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"8378fa7a-5fb5-44d9-986d-f34c5db00a22","timestamp":1746387315515,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
package/dist/client/index.html
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BBbCCCx2.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.BRj5A2lo.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CfVvufsh.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/MjlAM4Ld.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"
|
|
11
|
+
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/MjlAM4Ld.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1746387320984,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"8378fa7a-5fb5-44d9-986d-f34c5db00a22",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -512,6 +512,7 @@ const module = defineNuxtModule({
|
|
|
512
512
|
apiBaseUrl: "_locales",
|
|
513
513
|
routesLocaleLinks: {},
|
|
514
514
|
globalLocaleRoutes: {},
|
|
515
|
+
canonicalQueryWhitelist: ["page", "sort", "filter", "search", "q", "query", "tag"],
|
|
515
516
|
plural: (key, count, params, _locale, getTranslation) => {
|
|
516
517
|
const translation = getTranslation(key, params);
|
|
517
518
|
if (!translation) {
|
|
@@ -561,7 +562,8 @@ const module = defineNuxtModule({
|
|
|
561
562
|
hashMode: nuxt.options?.router?.options?.hashMode ?? false,
|
|
562
563
|
apiBaseUrl,
|
|
563
564
|
isSSG,
|
|
564
|
-
disablePageLocales: options.disablePageLocales ?? false
|
|
565
|
+
disablePageLocales: options.disablePageLocales ?? false,
|
|
566
|
+
canonicalQueryWhitelist: options.canonicalQueryWhitelist ?? []
|
|
565
567
|
};
|
|
566
568
|
if (typeof options.customRegexMatcher !== "undefined") {
|
|
567
569
|
const localeCodes = localeManager.locales.map((l) => l.code);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { joinURL } from "ufo";
|
|
1
|
+
import { joinURL, parseURL, withQuery } from "ufo";
|
|
2
2
|
import { isPrefixExceptDefaultStrategy, isNoPrefixStrategy } from "nuxt-i18n-micro-core";
|
|
3
3
|
import { unref, useRoute, useRuntimeConfig, watch, onUnmounted, ref, useNuxtApp } from "#imports";
|
|
4
4
|
export const useLocaleHead = ({ addDirAttribute = true, identifierAttribute = "id", addSeoAttributes = true, baseUrl = "/" } = {}) => {
|
|
@@ -7,28 +7,43 @@ export const useLocaleHead = ({ addDirAttribute = true, identifierAttribute = "i
|
|
|
7
7
|
link: [],
|
|
8
8
|
meta: []
|
|
9
9
|
});
|
|
10
|
+
function filterQuery(fullPath, whitelist) {
|
|
11
|
+
const { pathname, search } = parseURL(fullPath);
|
|
12
|
+
const params = new URLSearchParams(search);
|
|
13
|
+
const filtered = {};
|
|
14
|
+
for (const key of whitelist) {
|
|
15
|
+
if (params.has(key)) {
|
|
16
|
+
filtered[key] = params.get(key);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return withQuery(pathname, filtered);
|
|
20
|
+
}
|
|
10
21
|
function updateMeta() {
|
|
11
|
-
const { defaultLocale, strategy } = useRuntimeConfig().public.i18nConfig;
|
|
22
|
+
const { defaultLocale, strategy, canonicalQueryWhitelist } = useRuntimeConfig().public.i18nConfig;
|
|
12
23
|
const { $getLocales, $getLocale } = useNuxtApp();
|
|
13
24
|
const route = useRoute();
|
|
14
25
|
const locale = unref($getLocale());
|
|
15
26
|
const locales = unref($getLocales());
|
|
16
27
|
const routeName = (route.name ?? "").toString();
|
|
17
28
|
const currentLocale = unref($getLocales().find((loc) => loc.code === locale));
|
|
18
|
-
if (!currentLocale)
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
29
|
+
if (!currentLocale) return;
|
|
21
30
|
const currentIso = currentLocale.iso || locale;
|
|
22
31
|
const currentDir = currentLocale.dir || "auto";
|
|
23
32
|
let fullPath = unref(route.fullPath);
|
|
24
|
-
let ogUrl = joinURL(unref(baseUrl), fullPath);
|
|
25
33
|
if (!fullPath.startsWith("/")) {
|
|
26
34
|
fullPath = `/${fullPath}`;
|
|
27
35
|
}
|
|
28
36
|
const matchedLocale = locales.find((locale2) => fullPath.startsWith(`/${locale2.code}`));
|
|
37
|
+
let localizedPath = fullPath;
|
|
38
|
+
let ogUrl;
|
|
39
|
+
let canonicalPath;
|
|
29
40
|
if (routeName.startsWith("localized-") && matchedLocale) {
|
|
30
|
-
|
|
31
|
-
|
|
41
|
+
localizedPath = fullPath.slice(matchedLocale.code.length + 1);
|
|
42
|
+
canonicalPath = filterQuery(localizedPath, canonicalQueryWhitelist ?? []);
|
|
43
|
+
ogUrl = joinURL(unref(baseUrl), locale, canonicalPath);
|
|
44
|
+
} else {
|
|
45
|
+
canonicalPath = filterQuery(fullPath, canonicalQueryWhitelist ?? []);
|
|
46
|
+
ogUrl = joinURL(unref(baseUrl), canonicalPath);
|
|
32
47
|
}
|
|
33
48
|
metaObject.value = {
|
|
34
49
|
htmlAttrs: {
|
|
@@ -61,7 +76,8 @@ export const useLocaleHead = ({ addDirAttribute = true, identifierAttribute = "i
|
|
|
61
76
|
href: ogUrl
|
|
62
77
|
};
|
|
63
78
|
const alternateLinks = isNoPrefixStrategy(strategy) ? [] : alternateLocales.flatMap((loc) => {
|
|
64
|
-
const
|
|
79
|
+
const localizedPath2 = defaultLocale === loc.code && isPrefixExceptDefaultStrategy(strategy) ? canonicalPath : joinURL(loc.code, canonicalPath);
|
|
80
|
+
const href = joinURL(unref(baseUrl), localizedPath2);
|
|
65
81
|
const links = [{
|
|
66
82
|
[identifierAttribute]: `i18n-alternate-${loc.code}`,
|
|
67
83
|
rel: "alternate",
|
|
@@ -36,7 +36,7 @@ export default defineEventHandler(async (event) => {
|
|
|
36
36
|
const cacheName = join("_locales", getTranslationPath(locale, page));
|
|
37
37
|
const isThereAsset = await serverStorage.hasItem(cacheName);
|
|
38
38
|
if (isThereAsset) {
|
|
39
|
-
const rawContent = await serverStorage.
|
|
39
|
+
const rawContent = await serverStorage.getItemRaw(cacheName) ?? {};
|
|
40
40
|
return typeof rawContent === "string" ? JSON.parse(rawContent) : rawContent;
|
|
41
41
|
}
|
|
42
42
|
const createPaths = (locale2) => rootDirs.map((dir) => ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.87.0",
|
|
4
4
|
"description": "Nuxt I18n Micro is a lightweight, high-performance internationalization module for Nuxt, designed to handle multi-language support with minimal overhead, fast build times, and efficient runtime performance.",
|
|
5
5
|
"repository": "s00d/nuxt-i18n-micro",
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
"globby": "^14.1.0",
|
|
60
60
|
"sirv": "^2.0.4",
|
|
61
61
|
"ufo": "^1.5.4",
|
|
62
|
-
"nuxt-i18n-micro-
|
|
63
|
-
"nuxt-i18n-micro-
|
|
64
|
-
"nuxt-i18n-micro-
|
|
62
|
+
"nuxt-i18n-micro-types": "1.0.6",
|
|
63
|
+
"nuxt-i18n-micro-core": "1.0.18",
|
|
64
|
+
"nuxt-i18n-micro-test-utils": "1.0.6"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@nuxt/devtools": "^2.1.0",
|
|
@@ -108,6 +108,7 @@
|
|
|
108
108
|
"lint": "eslint .",
|
|
109
109
|
"lint:fix": "eslint . --fix",
|
|
110
110
|
"test": "playwright test",
|
|
111
|
+
"test:vitest": "vitest run",
|
|
111
112
|
"test:watch": "vitest watch",
|
|
112
113
|
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
|
|
113
114
|
"test:workspaces": "pnpm recursive run test",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"9b03c3ea-26a1-4619-b39e-b42f797680ba","timestamp":1745997666200,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|