Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docs): Typesafe metadata object #52252

Merged
merged 14 commits into from
Jul 10, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/02-app/02-api-reference/04-functions/generate-metadata.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export const metadata: Metadata = {
```jsx filename="app/layout.js" switcher
import { Metadata } from 'next'
carlos-menezes marked this conversation as resolved.
Show resolved Hide resolved

export const metadata: Metadata = {
export const metadata = {
title: {
default: '...',
template: '...',
Expand All @@ -193,15 +193,15 @@ 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 = {
export const metadata: Metadata = {
carlos-menezes marked this conversation as resolved.
Show resolved Hide resolved
title: {
default: 'Acme',
},
}
```

```tsx filename="app/about/page.tsx"
export const metadata = {}
export const metadata: Metadata = {}
carlos-menezes marked this conversation as resolved.
Show resolved Hide resolved

// Output: <title>Acme</title>
```
Expand All @@ -224,7 +224,7 @@ export const metadata: Metadata = {
```jsx filename="app/layout.js" switcher
import { Metadata } from 'next'
styfle marked this conversation as resolved.
Show resolved Hide resolved

export const metadata: Metadata = {
export const metadata = {
title: {
template: '%s | Acme',
default: 'Acme', // a default is required when creating a template
Expand All @@ -245,7 +245,7 @@ export const metadata: Metadata = {
```jsx filename="app/about/page.js" switcher
import { Metadata } from 'next'
carlos-menezes marked this conversation as resolved.
Show resolved Hide resolved

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

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

```tsx
export const metadata = {
export const metadata: Metadata = {
carlos-menezes marked this conversation as resolved.
Show resolved Hide resolved
robots: {
index: false,
follow: true,
Expand Down