Skip to content

Commit

Permalink
chore(docs): Typesafe metadata object (#52252)
Browse files Browse the repository at this point in the history
Adds missing `Metadata` type to a few declarations.

---------

Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
  • Loading branch information
4 people committed Jul 10, 2023
1 parent dfebdb7 commit 9ea188a
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions docs/02-app/02-api-reference/04-functions/generate-metadata.mdx
Expand Up @@ -177,9 +177,7 @@ export const metadata: Metadata = {
```

```jsx filename="app/layout.js" switcher
import { Metadata } from 'next'

export const metadata: Metadata = {
export const metadata = {
title: {
default: '...',
template: '...',
Expand All @@ -193,15 +191,19 @@ export const metadata: Metadata = {
`title.default` can be used to provide a **fallback title** to child route segments that don't define a `title`.

```tsx filename="app/layout.tsx"
export const metadata = {
import type { Metadata } from 'next'

export const metadata: Metadata = {
title: {
default: 'Acme',
},
}
```

```tsx filename="app/about/page.tsx"
export const metadata = {}
import type { Metadata } from 'next'

export const metadata: Metadata = {}

// Output: <title>Acme</title>
```
Expand All @@ -222,9 +224,7 @@ export const metadata: Metadata = {
```

```jsx filename="app/layout.js" switcher
import { Metadata } from 'next'

export const metadata: Metadata = {
export const metadata = {
title: {
template: '%s | Acme',
default: 'Acme', // a default is required when creating a template
Expand All @@ -243,9 +243,7 @@ export const metadata: Metadata = {
```

```jsx filename="app/about/page.js" switcher
import { Metadata } from 'next'

export const metadata: Metadata = {
export const metadata = {
title: 'About',
}

Expand Down Expand Up @@ -520,7 +518,9 @@ export const metadata = {
### `robots`

```tsx
export const metadata = {
import type { Metadata } from 'next'

export const metadata: Metadata = {
robots: {
index: false,
follow: true,
Expand Down

0 comments on commit 9ea188a

Please sign in to comment.