@windrun-huaiin/lib 21.0.0 → 23.0.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/seo-metadata.d.ts +42 -0
- package/dist/seo-metadata.d.ts.map +1 -0
- package/dist/seo-metadata.js +34 -0
- package/dist/seo-metadata.mjs +32 -0
- package/package.json +1 -1
- package/src/index.ts +1 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface CreateLocalizedSiteMetadataOptions {
|
|
2
|
+
locale: string;
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
locales: readonly string[];
|
|
5
|
+
defaultLocale: string;
|
|
6
|
+
localePrefixAsNeeded: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function createLocalizedSiteMetadata(options: CreateLocalizedSiteMetadataOptions): Promise<{
|
|
9
|
+
title: any;
|
|
10
|
+
description: any;
|
|
11
|
+
keywords: any;
|
|
12
|
+
alternates: {
|
|
13
|
+
canonical: string;
|
|
14
|
+
languages: {
|
|
15
|
+
[k: string]: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
icons: readonly [{
|
|
19
|
+
readonly rel: "icon";
|
|
20
|
+
readonly type: "image/png";
|
|
21
|
+
readonly sizes: "16x16";
|
|
22
|
+
readonly url: "/favicon-16x16.png";
|
|
23
|
+
}, {
|
|
24
|
+
readonly rel: "icon";
|
|
25
|
+
readonly type: "image/png";
|
|
26
|
+
readonly sizes: "32x32";
|
|
27
|
+
readonly url: "/favicon-32x32.png";
|
|
28
|
+
}, {
|
|
29
|
+
readonly rel: "icon";
|
|
30
|
+
readonly type: "image/ico";
|
|
31
|
+
readonly url: "/favicon.ico";
|
|
32
|
+
}, {
|
|
33
|
+
readonly rel: "apple-touch-icon";
|
|
34
|
+
readonly sizes: "180x180";
|
|
35
|
+
readonly url: "/favicon-180x180.png";
|
|
36
|
+
}, {
|
|
37
|
+
readonly rel: "android-chrome";
|
|
38
|
+
readonly sizes: "512x512";
|
|
39
|
+
readonly url: "/favicon-512x512.png";
|
|
40
|
+
}];
|
|
41
|
+
}>;
|
|
42
|
+
//# sourceMappingURL=seo-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seo-metadata.d.ts","sourceRoot":"","sources":["../src/seo-metadata.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,kCAAkC;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAUD,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoB5C"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var server = require('next-intl/server');
|
|
5
|
+
var utils = require('./utils.js');
|
|
6
|
+
|
|
7
|
+
const DEFAULT_SITE_ICONS = [
|
|
8
|
+
{ rel: 'icon', type: 'image/png', sizes: '16x16', url: '/favicon-16x16.png' },
|
|
9
|
+
{ rel: 'icon', type: 'image/png', sizes: '32x32', url: '/favicon-32x32.png' },
|
|
10
|
+
{ rel: 'icon', type: 'image/ico', url: '/favicon.ico' },
|
|
11
|
+
{ rel: 'apple-touch-icon', sizes: '180x180', url: '/favicon-180x180.png' },
|
|
12
|
+
{ rel: 'android-chrome', sizes: '512x512', url: '/favicon-512x512.png' },
|
|
13
|
+
];
|
|
14
|
+
function createLocalizedSiteMetadata(options) {
|
|
15
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const { baseUrl, defaultLocale, locale, localePrefixAsNeeded, locales } = options;
|
|
17
|
+
const t = yield server.getTranslations({ locale, namespace: 'home' });
|
|
18
|
+
return {
|
|
19
|
+
title: t('webTitle'),
|
|
20
|
+
description: t('webDescription'),
|
|
21
|
+
keywords: t('keywords'),
|
|
22
|
+
alternates: {
|
|
23
|
+
canonical: `${baseUrl}${utils.getAsNeededLocalizedUrl(locale, '/', localePrefixAsNeeded, defaultLocale)}`,
|
|
24
|
+
languages: Object.fromEntries(locales.map((siteLocale) => [
|
|
25
|
+
siteLocale,
|
|
26
|
+
`${baseUrl}${utils.getAsNeededLocalizedUrl(siteLocale, '/', localePrefixAsNeeded, defaultLocale)}`,
|
|
27
|
+
])),
|
|
28
|
+
},
|
|
29
|
+
icons: DEFAULT_SITE_ICONS,
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.createLocalizedSiteMetadata = createLocalizedSiteMetadata;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { __awaiter } from 'tslib';
|
|
2
|
+
import { getTranslations } from 'next-intl/server';
|
|
3
|
+
import { getAsNeededLocalizedUrl } from './utils.mjs';
|
|
4
|
+
|
|
5
|
+
const DEFAULT_SITE_ICONS = [
|
|
6
|
+
{ rel: 'icon', type: 'image/png', sizes: '16x16', url: '/favicon-16x16.png' },
|
|
7
|
+
{ rel: 'icon', type: 'image/png', sizes: '32x32', url: '/favicon-32x32.png' },
|
|
8
|
+
{ rel: 'icon', type: 'image/ico', url: '/favicon.ico' },
|
|
9
|
+
{ rel: 'apple-touch-icon', sizes: '180x180', url: '/favicon-180x180.png' },
|
|
10
|
+
{ rel: 'android-chrome', sizes: '512x512', url: '/favicon-512x512.png' },
|
|
11
|
+
];
|
|
12
|
+
function createLocalizedSiteMetadata(options) {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
const { baseUrl, defaultLocale, locale, localePrefixAsNeeded, locales } = options;
|
|
15
|
+
const t = yield getTranslations({ locale, namespace: 'home' });
|
|
16
|
+
return {
|
|
17
|
+
title: t('webTitle'),
|
|
18
|
+
description: t('webDescription'),
|
|
19
|
+
keywords: t('keywords'),
|
|
20
|
+
alternates: {
|
|
21
|
+
canonical: `${baseUrl}${getAsNeededLocalizedUrl(locale, '/', localePrefixAsNeeded, defaultLocale)}`,
|
|
22
|
+
languages: Object.fromEntries(locales.map((siteLocale) => [
|
|
23
|
+
siteLocale,
|
|
24
|
+
`${baseUrl}${getAsNeededLocalizedUrl(siteLocale, '/', localePrefixAsNeeded, defaultLocale)}`,
|
|
25
|
+
])),
|
|
26
|
+
},
|
|
27
|
+
icons: DEFAULT_SITE_ICONS,
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { createLocalizedSiteMetadata };
|
package/package.json
CHANGED
package/src/index.ts
CHANGED