({
title,
description,
path = '',
image,
keywords = [],
noindex = false,
type = 'website',
}: CreateMetadataOptions)
| 13 | } |
| 14 | |
| 15 | export function createMetadata({ |
| 16 | title, |
| 17 | description, |
| 18 | path = '', |
| 19 | image, |
| 20 | keywords = [], |
| 21 | noindex = false, |
| 22 | type = 'website', |
| 23 | }: CreateMetadataOptions): Metadata { |
| 24 | const url = `${app.url}${path}` |
| 25 | const isHomePage = title === app.name |
| 26 | const fullTitle = isHomePage ? title : `${title} / ${app.name}` |
| 27 | |
| 28 | const shouldIncludeImage = image !== null |
| 29 | const ogImageUrl = image === null ? undefined : image || ogImage({ title, description }) |
| 30 | |
| 31 | return { |
| 32 | title: isHomePage ? { absolute: title } : title, |
| 33 | description, |
| 34 | alternates: { |
| 35 | canonical: url, |
| 36 | }, |
| 37 | keywords: keywords.length > 0 ? keywords : undefined, |
| 38 | openGraph: { |
| 39 | title: fullTitle, |
| 40 | description, |
| 41 | url, |
| 42 | siteName: app.name, |
| 43 | locale: 'en_US', |
| 44 | ...(shouldIncludeImage && ogImageUrl && { images: [{ url: ogImageUrl }] }), |
| 45 | type, |
| 46 | }, |
| 47 | twitter: { |
| 48 | card: 'summary_large_image', |
| 49 | title: fullTitle, |
| 50 | description, |
| 51 | ...(shouldIncludeImage && ogImageUrl && { images: [ogImageUrl] }), |
| 52 | site: '@intentui', |
| 53 | creator: `@${app.author.username}`, |
| 54 | }, |
| 55 | ...(noindex && { robots: { index: false, follow: false } }), |
| 56 | } |
| 57 | } |
no test coverage detected