Unverified Commit b294073d authored by Shu Ding's avatar Shu Ding Committed by GitHub

Add more JSDoc to metadata interface (#45526)

Over time we need to add that to all types with example values and what
does the tag looks like as a result.

Co-authored with some AI.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
parent 3fa47988
......@@ -29,39 +29,110 @@ import type {
import type { OpenGraph, ResolvedOpenGraph } from './opengraph-types'
import type { ResolvedTwitterMetadata, Twitter } from './twitter-types'
export interface Metadata {
// origin and base path for absolute urls for various metadata links such as
// opengraph-image
/**
* Metadata interface to describe all the metadata fields that can be set in a document.
* @interface
*/
interface Metadata {
/**
* The base path and origin for absolute urls for various metadata links such as OpenGraph images.
* @type {null | URL}
*/
metadataBase?: null | URL
// The Document title
/**
* The document title.
* @type {null | string | TemplateString}
*/
title?: null | string | TemplateString
// The Document description, and optionally the opengraph and twitter descriptions
/**
* The document description, and optionally the OpenGraph and twitter descriptions.
* @type {null | string}
*/
description?: null | string
// Standard metadata names
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta/name
/**
* The application name.
* @type {null | string}
*/
applicationName?: null | string
/**
* The authors of the document.
* @type {null | Author | Array<Author>}
*/
authors?: null | Author | Array<Author>
/**
* The generator used for the document.
* @type {null | string}
*/
generator?: null | string
// if you provide an array it will be flattened into a single tag with comma separation
/**
* The keywords for the document. If an array is provided, it will be flattened into a single tag with comma separation.
* @type {null | string | Array<string>}
*/
keywords?: null | string | Array<string>
/**
* The referrer setting for the document.
* @type {null | ReferrerEnum}
*/
referrer?: null | ReferrerEnum
/**
* The theme color for the document.
* @type {null | string}
*/
themeColor?: null | string
/**
* The color scheme for the document.
* @type {null | ColorSchemeEnum}
*/
colorScheme?: null | ColorSchemeEnum
/**
* The viewport setting for the document.
* @type {null | string | Viewport}
*/
viewport?: null | string | Viewport
/**
* The creator of the document.
* @type {null | string}
*/
creator?: null | string
/**
* The publisher of the document.
* @type {null | string}
*/
publisher?: null | string
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta/name#other_metadata_names
/**
* The robots setting for the document.
* @type {null | string | Robots}
*/
robots?: null | string | Robots
// The canonical and alternate URLs for this location
/**
* The canonical and alternate URLs for the document.
* @type {null | AlternateURLs}
*/
alternates?: null | AlternateURLs
// Defaults to rel="icon" but the Icons type can be used
// to get more specific about rel types
/**
* The icons for the document. Defaults to rel="icon".
* @type {null | IconURL | Array<Icon> | Icons}
*/
icons?: null | IconURL | Array<Icon> | Icons
/**
......@@ -81,59 +152,111 @@ export interface Metadata {
*/
openGraph?: null | OpenGraph
/**
* The Twitter metadata for the document.
* @type {null | Twitter}
*/
twitter?: null | Twitter
// common verification tokens
/**
* The common verification tokens for the document.
* @type {Verification}
*/
verification?: Verification
// Apple web app metadata
// https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html
/**
* The Apple web app metadata for the document.
* https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html
* @type {null | boolean | AppleWebApp}
*/
appleWebApp?: null | boolean | AppleWebApp
// Should devices try to interpret various formats and make actionable links
// out of them? The canonical example is telephone numbers on mobile that can
// be clicked to dial
/**
* Indicates if devices should try to interpret various formats and make actionable links out of them. For example it controles
* if telephone numbers on mobile that can be clicked to dial or not.
* @type {null | FormatDetection}
*/
formatDetection?: null | FormatDetection
// meta name="apple-itunes-app"
/**
* The metadata for the iTunes App.
* It adds the `name="apple-itunes-app"` meta tag.
* @type {null | ItunesApp}
*/
itunes?: null | ItunesApp
// meta name="abstract"
// A brief description of what this web-page is about.
// Not recommended, superceded by description.
// https://www.metatags.org/all-meta-tags-overview/meta-name-abstract/
/**
* A brief description of what this web-page is about. Not recommended, superceded by description.
* It adds the `name="abstract"` meta tag.
* https://www.metatags.org/all-meta-tags-overview/meta-name-abstract/
* @type {null | string}
*/
abstract?: null | string
// Facebook AppLinks
/**
* The Facebook AppLinks metadata for the document.
* @type {null | AppLinks}
*/
appLinks?: null | AppLinks
// link rel properties
/**
* The archives link rel property.
* @type {null | string | Array<string>}
*/
archives?: null | string | Array<string>
/**
* The assets link rel property.
* @type {null | string | Array<string>}
*/
assets?: null | string | Array<string>
/**
* The bookmarks link rel property.
* @type {null | string | Array<string>}
*/
bookmarks?: null | string | Array<string> // This is technically against HTML spec but is used in wild
// meta name properties
/**
* The category meta name property.
* @type {null | string}
*/
category?: null | string
/**
* The classification meta name property.
* @type {null | string}
*/
classification?: null | string
// Arbitrary name/value pairs
/**
* Arbitrary name/value pairs for the document.
* @type {{ [name: string]: string | number | Array<string | number> }}
*/
other?: {
[name: string]: string | number | Array<string | number>
}
/**
* Deprecated options that have a preferred method
* */
// Use appWebApp to configure apple-mobile-web-app-capable which provides
// https://www.appsloveworld.com/coding/iphone/11/difference-between-apple-mobile-web-app-capable-and-apple-touch-fullscreen-ipho
* Deprecated options that have a preferred method.
* Use appWebApp to configure apple-mobile-web-app-capable which provides
* https://www.appsloveworld.com/coding/iphone/11/difference-between-apple-mobile-web-app-capable-and-apple-touch-fullscreen-ipho
* @deprecated
*/
'apple-touch-fullscreen'?: never
// Obsolete since iOS 7. use icons.apple or "app-touch-icon" instead
// https://web.dev/apple-touch-icon/
/**
* Deprecated options that have a preferred method.
* Obsolete since iOS 7. use icons.apple or "app-touch-icon" instead
* https://web.dev/apple-touch-icon/
* @deprecated
*/
'apple-touch-icon-precomposed'?: never
}
export interface ResolvedMetadata {
interface ResolvedMetadata {
// origin and base path for absolute urls for various metadata links such as
// opengraph-image
metadataBase: null | URL
......@@ -223,3 +346,4 @@ export interface ResolvedMetadata {
}
export type ResolvingMetadata = Promise<ResolvedMetadata>
export { Metadata, ResolvedMetadata }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment