diff --git a/packages/schema/src/link.ts b/packages/schema/src/link.ts index d31cf7d..bccd366 100644 --- a/packages/schema/src/link.ts +++ b/packages/schema/src/link.ts @@ -1,4 +1,4 @@ -import type { HttpEventAttributes } from '@zhead/schema/src/attributes' +import type { HttpEventAttributes } from './attributes' export type LinkRelTypes = 'alternate' | 'author' | @@ -59,7 +59,7 @@ export interface Link extends HttpEventAttributes { * The value must be a string that matches the CSS production, * defining a suggested color that user agents can use to customize the display * of the icon that the user sees when they pin your site. - * + * * @see https://html.spec.whatwg.org/multipage/semantics.html#attr-link-color */ color?: string @@ -155,7 +155,7 @@ export interface Link extends HttpEventAttributes { * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-rel */ - rel?: LinkRelTypes | string + rel?: LinkRelTypes | (string & Record) /** * This attribute defines the sizes of the icons for visual media contained in the resource. * It must be present only if the rel contains a value of icon or a non-standard type @@ -163,7 +163,7 @@ export interface Link extends HttpEventAttributes { * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-sizes */ - sizes?: 'any' | '16x16x' | '32x32' | '64x64' | '180x180' | string + sizes?: 'any' | '16x16x' | '32x32' | '64x64' | '180x180' | (string & Record) /** * The title attribute has special semantics on the element. * When used on a it defines a default or an alternate stylesheet. @@ -255,7 +255,7 @@ export interface Link extends HttpEventAttributes { 'video/3gpp' | 'audio/3gpp' | 'video/3gpp2' | - 'audio/3gpp2' | string + 'audio/3gpp2' | (string & Record) /** * This attribute defines the unique ID. */ diff --git a/packages/schema/src/meta.ts b/packages/schema/src/meta.ts index 042ab4e..a03bc1b 100644 --- a/packages/schema/src/meta.ts +++ b/packages/schema/src/meta.ts @@ -1,28 +1,83 @@ -import type { MetaFlat } from './meta-flat' +export type MetaNames = +'charset' | +'description' | +'color-scheme' | +'application-name' | +'author' | +'creator' | +'publisher' | +'generator' | +'referrer' | +'viewport' | +'robots' | +'google' | +'googlebot' | +'google-site-verification' | +'rating' | +'fb:app_id' | +'theme-color' | +'mobile-web-app-capable' | +'apple-mobile-web-app-capable' | +'apple-mobile-web-app-status-bar-style' | +'apple-mobile-web-app-title' | +'apple-itunes-app' | +'format-detection' | +'msapplication-TileImage' | +'msapplication-TileColor' | +'msapplication-Config' | +'content-security-policy' | +'content-type' | +'default-style' | +'x-ua-compatible' | +'refresh' -type Kebab = - T extends `${infer F}${infer R}` ? - Kebab ? '' : '-'}${Lowercase}`> : - A - -type KebabColon = - T extends `${infer F}${infer R}` ? - KebabColon ? '' : ':'}${Lowercase}`> : - A - -type FixCase = - T extends 'fbAppId' ? 'fb:app_id' : - T extends 'ogImageSecureUrl' ? 'og:image:secure_url' : - T extends 'ogVideoSecureUrl' ? 'og:video:secure_url' : - T extends - `og${infer R}` | `twitter${infer R}` - ? KebabColon : Kebab - -type ContentKeys = T extends - `og${infer R}` | `twitter${infer R}` ? never : T - -type PropertyKeys = T extends - `og${infer R}` | `twitter${infer R}` ? T : never +export type MetaProperties = 'og:url' | +'og:title' | +'og:description' | +'og:type' | +'og:locale' | +'og:locale:alternate' | +'og:determiner' | +'og:site:name' | +'og:video' | +'og:video:url' | +'og:video:secure_url' | +'og:video:type' | +'og:video:width' | +'og:video:height' | +'og:image' | +'og:image:url' | +'og:image:secure_url' | +'og:image:type' | +'og:image:width' | +'og:image:height' | +'fb:app:id' | +'twitter:card' | +'twitter:title' | +'twitter:description' | +'twitter:image' | +'twitter:image:alt' | +'twitter:site' | +'twitter:site:id' | +'twitter:creator' | +'twitter:creator:id' | +'twitter:player' | +'twitter:player:width' | +'twitter:player:height' | +'twitter:player:stream' | +'twitter:app:name:iphone' | +'twitter:app:id:iphone' | +'twitter:app:url:iphone' | +'twitter:app:name:ipad' | +'twitter:app:id:ipad' | +'twitter:app:url:ipad' | +'twitter:app:name:googleplay' | +'twitter:app:id:googleplay' | +'twitter:app:url:googleplay' | +'twitter:data:1' | +'twitter:label:1' | +'twitter:data:2' | +'twitter:label:2' export interface Meta { /** @@ -34,13 +89,13 @@ export interface Meta { * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#attr-charset */ - charset?: string + charset?: 'utf-8' | (string & Record) /** * This attribute contains the value for the http-equiv or name attribute, depending on which is used. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#attr-content */ - content?: (MetaFlat[keyof MetaFlat] extends string ? MetaFlat[keyof MetaFlat] : never) | string | number + content?: string /** * Defines a pragma directive. The attribute is named http-equiv(alent) because all the allowed values are names of * particular HTTP headers. @@ -59,13 +114,13 @@ export interface Meta { * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#attr-name */ - name?: FixCase> | string + name?: MetaNames | (string & Record) /** * The property attribute is used to define a property associated with the content attribute. * * Mainly used for og and twitter meta tags. */ - property?: FixCase> | string + property?: MetaProperties | (string & Record) /** * This attribute defines the unique ID. */