feat: add alternate rss xml meta tag

This commit is contained in:
Timothy Lin 2023-07-09 23:29:39 +08:00
parent 202fa62b3f
commit 988b1aa2ce
3 changed files with 17 additions and 2 deletions

View File

@ -32,6 +32,9 @@ export const metadata: Metadata = {
},
alternates: {
canonical: './',
types: {
'application/rss+xml': `${siteMetadata.siteUrl}/feed.xml`,
},
},
robots: {
index: true,

View File

@ -5,9 +5,11 @@ interface PageSEOProps {
title: string
description?: string
image?: string
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any
}
export function genPageMetadata({ title, description, image }: PageSEOProps): Metadata {
export function genPageMetadata({ title, description, image, ...rest }: PageSEOProps): Metadata {
return {
title,
openGraph: {
@ -24,5 +26,6 @@ export function genPageMetadata({ title, description, image }: PageSEOProps): Me
card: 'summary_large_image',
images: image ? [image] : [siteMetadata.socialBanner],
},
...rest,
}
}

View File

@ -8,7 +8,16 @@ import { Metadata } from 'next'
export async function generateMetadata({ params }: { params: { tag: string } }): Promise<Metadata> {
const tag = params.tag
return genPageMetadata({ title: tag, description: `${siteMetadata.title} ${tag} tagged content` })
return genPageMetadata({
title: tag,
description: `${siteMetadata.title} ${tag} tagged content`,
alternates: {
canonical: './',
types: {
'application/rss+xml': `${siteMetadata.siteUrl}/tags/${tag}/feed.xml`,
},
},
})
}
export const generateStaticParams = async () => {