@i18n-micro/types 1.2.4 → 1.2.6
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/README.md +15 -0
- package/dist/index.d.cts +36 -1
- package/dist/index.d.ts +36 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -111,6 +111,21 @@ Represents global route configurations for different locales.
|
|
|
111
111
|
|
|
112
112
|
Represents a key-value pair of translations.
|
|
113
113
|
|
|
114
|
+
#### Page-level SEO head (`useI18nHead`)
|
|
115
|
+
|
|
116
|
+
Types for per-page i18n SEO overrides: `I18nHeadInput`, `I18nHeadLink`, `I18nHeadMeta`, and `I18nHeadDisableGroup`. Use them in page helpers or when calling `useI18nHead` from `@i18n-micro/types` for typed `meta`, `link`, `replace`, and `disable` options.
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import type { I18nHeadInput } from '@i18n-micro/types'
|
|
120
|
+
|
|
121
|
+
export function buildArticleHead(article: Article): I18nHeadInput {
|
|
122
|
+
return {
|
|
123
|
+
meta: [{ property: 'og:title', content: article.title }],
|
|
124
|
+
replace: { canonical: article.canonicalUrl, ogUrl: article.canonicalUrl },
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
114
129
|
#### `Translation`
|
|
115
130
|
|
|
116
131
|
Represents a translation value, which can be a string, number, boolean, nested translations, or `null`.
|
package/dist/index.d.cts
CHANGED
|
@@ -60,7 +60,8 @@ export interface Locale {
|
|
|
60
60
|
iso?: string;
|
|
61
61
|
/**
|
|
62
62
|
* Open Graph locale for `og:locale` / `og:locale:alternate` meta `content` (e.g. `ar_AE`).
|
|
63
|
-
*
|
|
63
|
+
* When omitted, `iso` is converted to OG format when possible (`en-US` → `en_US`).
|
|
64
|
+
* If conversion is not possible, `og:locale` tags are not emitted (dev warning when `missingWarn` is enabled).
|
|
64
65
|
*/
|
|
65
66
|
og?: string;
|
|
66
67
|
/**
|
|
@@ -532,5 +533,39 @@ export type Translation = CleanTranslation | unknown;
|
|
|
532
533
|
export interface Translations {
|
|
533
534
|
[key: string]: Translation;
|
|
534
535
|
}
|
|
536
|
+
/** Link entry for page-level i18n head overrides (`useI18nHead`). */
|
|
537
|
+
export interface I18nHeadLink {
|
|
538
|
+
rel: string;
|
|
539
|
+
href: string;
|
|
540
|
+
hreflang?: string;
|
|
541
|
+
[key: string]: string | undefined;
|
|
542
|
+
}
|
|
543
|
+
/** Meta entry for page-level i18n head overrides (`useI18nHead`). */
|
|
544
|
+
export interface I18nHeadMeta {
|
|
545
|
+
[key: string]: string | undefined;
|
|
546
|
+
}
|
|
547
|
+
/** Groups of built-in i18n SEO tags that can be disabled per page. */
|
|
548
|
+
export type I18nHeadDisableGroup = 'hreflang' | 'x-default' | 'canonical' | 'og' | 'og-alternates' | 'html';
|
|
549
|
+
/** Page-level overrides merged on top of `useLocaleHead` output. */
|
|
550
|
+
export interface I18nHeadInput {
|
|
551
|
+
/** Extra or overriding `<html>` attributes. */
|
|
552
|
+
htmlAttrs?: Record<string, string>;
|
|
553
|
+
/** Meta tags appended after base i18n tags (deduped by `id` / `property` / `name`). */
|
|
554
|
+
meta?: I18nHeadMeta[];
|
|
555
|
+
/** Link tags appended after base i18n tags (deduped by `id` / `rel` + `hreflang`). */
|
|
556
|
+
link?: I18nHeadLink[];
|
|
557
|
+
/** Replace or remove specific built-in i18n SEO tags. */
|
|
558
|
+
replace?: {
|
|
559
|
+
canonical?: string | false;
|
|
560
|
+
hreflang?: I18nHeadLink[] | false;
|
|
561
|
+
xDefault?: I18nHeadLink | false;
|
|
562
|
+
ogLocale?: string | false;
|
|
563
|
+
ogUrl?: string | false;
|
|
564
|
+
/** Locale codes for `og:locale:alternate` (resolved via `locale.og` / `iso`). */
|
|
565
|
+
ogAlternates?: string[] | false;
|
|
566
|
+
};
|
|
567
|
+
/** Disable built-in i18n SEO tag groups for this page. */
|
|
568
|
+
disable?: I18nHeadDisableGroup[];
|
|
569
|
+
}
|
|
535
570
|
declare const init: () => void;
|
|
536
571
|
export { init };
|
package/dist/index.d.ts
CHANGED
|
@@ -60,7 +60,8 @@ export interface Locale {
|
|
|
60
60
|
iso?: string;
|
|
61
61
|
/**
|
|
62
62
|
* Open Graph locale for `og:locale` / `og:locale:alternate` meta `content` (e.g. `ar_AE`).
|
|
63
|
-
*
|
|
63
|
+
* When omitted, `iso` is converted to OG format when possible (`en-US` → `en_US`).
|
|
64
|
+
* If conversion is not possible, `og:locale` tags are not emitted (dev warning when `missingWarn` is enabled).
|
|
64
65
|
*/
|
|
65
66
|
og?: string;
|
|
66
67
|
/**
|
|
@@ -532,5 +533,39 @@ export type Translation = CleanTranslation | unknown;
|
|
|
532
533
|
export interface Translations {
|
|
533
534
|
[key: string]: Translation;
|
|
534
535
|
}
|
|
536
|
+
/** Link entry for page-level i18n head overrides (`useI18nHead`). */
|
|
537
|
+
export interface I18nHeadLink {
|
|
538
|
+
rel: string;
|
|
539
|
+
href: string;
|
|
540
|
+
hreflang?: string;
|
|
541
|
+
[key: string]: string | undefined;
|
|
542
|
+
}
|
|
543
|
+
/** Meta entry for page-level i18n head overrides (`useI18nHead`). */
|
|
544
|
+
export interface I18nHeadMeta {
|
|
545
|
+
[key: string]: string | undefined;
|
|
546
|
+
}
|
|
547
|
+
/** Groups of built-in i18n SEO tags that can be disabled per page. */
|
|
548
|
+
export type I18nHeadDisableGroup = 'hreflang' | 'x-default' | 'canonical' | 'og' | 'og-alternates' | 'html';
|
|
549
|
+
/** Page-level overrides merged on top of `useLocaleHead` output. */
|
|
550
|
+
export interface I18nHeadInput {
|
|
551
|
+
/** Extra or overriding `<html>` attributes. */
|
|
552
|
+
htmlAttrs?: Record<string, string>;
|
|
553
|
+
/** Meta tags appended after base i18n tags (deduped by `id` / `property` / `name`). */
|
|
554
|
+
meta?: I18nHeadMeta[];
|
|
555
|
+
/** Link tags appended after base i18n tags (deduped by `id` / `rel` + `hreflang`). */
|
|
556
|
+
link?: I18nHeadLink[];
|
|
557
|
+
/** Replace or remove specific built-in i18n SEO tags. */
|
|
558
|
+
replace?: {
|
|
559
|
+
canonical?: string | false;
|
|
560
|
+
hreflang?: I18nHeadLink[] | false;
|
|
561
|
+
xDefault?: I18nHeadLink | false;
|
|
562
|
+
ogLocale?: string | false;
|
|
563
|
+
ogUrl?: string | false;
|
|
564
|
+
/** Locale codes for `og:locale:alternate` (resolved via `locale.og` / `iso`). */
|
|
565
|
+
ogAlternates?: string[] | false;
|
|
566
|
+
};
|
|
567
|
+
/** Disable built-in i18n SEO tag groups for this page. */
|
|
568
|
+
disable?: I18nHeadDisableGroup[];
|
|
569
|
+
}
|
|
535
570
|
declare const init: () => void;
|
|
536
571
|
export { init };
|