2024-09-07 20:56:08 +02:00
import { Metadata } from "next" ;
import clientPromise from "@/lib/db" ;
interface Page {
title : string ;
content : string ;
}
// baseURL [ENV]
2024-11-01 09:56:38 +01:00
export async function generateMetadata ( props : {
params : Promise < { slug : "string" } > ;
2024-09-07 20:56:08 +02:00
} ) {
2024-11-01 09:56:38 +01:00
const params = await props . params ;
2024-09-07 20:56:08 +02:00
let page : Page = {
title : "unknown mod" ,
content : "unknown mod"
} ;
let notFound = false ;
try {
const client = await clientPromise ;
2024-09-07 21:11:11 +02:00
const db = client . db ( process . env . MONGODB_DB ) ;
2024-09-07 20:56:08 +02:00
const fetchedPage = ( await db
. collection ( "pages" )
. findOne ( { slug : params.slug } ) ) as unknown as Page ;
if ( fetchedPage ) {
page = fetchedPage ;
} else {
notFound = true ;
}
} catch ( err ) { }
2024-09-07 21:16:02 +02:00
if ( notFound ) {
return {
title : "404 Not Found - SVR.JS" ,
openGraph : {
title : "404 Not Found - SVR.JS"
} ,
twitter : {
title : "404 Not Found - SVR.JS"
}
} ;
}
2024-09-07 20:56:08 +02:00
return {
title : ` ${ page . title } change log - SVR.JS ` ,
description : ` Keep track of the latest updates and improvements for ${ page . title } with our comprehensive change log. Discover new features, bug fixes, and enhancements for each release of this SVR.JS mod. ` ,
2024-11-25 07:11:36 +01:00
alternates : {
canonical : ` ${ process . env . NEXT_PUBLIC_WEBSITE_URL } /changelog/ ${ params . slug } `
} ,
2024-09-07 20:56:08 +02:00
openGraph : {
title : ` ${ page . title } change log - SVR.JS ` ,
description : ` Keep track of the latest updates and improvements for ${ page . title } with our comprehensive change log. Discover new features, bug fixes, and enhancements for each release of this SVR.JS mod. ` ,
2024-09-08 13:16:43 +02:00
url : ` ${ process . env . NEXT_PUBLIC_WEBSITE_URL } /changelog/ ${ params . slug } ` ,
2024-09-07 20:56:08 +02:00
type : "website" ,
images : [
{
2024-09-08 13:16:43 +02:00
url : ` ${ process . env . NEXT_PUBLIC_WEBSITE_URL } /metadata/svrjs-cover.png ` ,
2024-09-07 20:56:08 +02:00
width : 800 ,
height : 600 ,
alt : ` ${ page . title } change log - SVR.JS `
}
]
} ,
twitter : {
card : "summary_large_image" ,
site : "@SVR_JS" ,
title : ` ${ page . title } change log - SVR.JS ` ,
description : ` Keep track of the latest updates and improvements for ${ page . title } with our comprehensive change log. Discover new features, bug fixes, and enhancements for each release of this SVR.JS mod. ` ,
2024-09-08 13:16:43 +02:00
images : [
` ${ process . env . NEXT_PUBLIC_WEBSITE_URL } /metadata/svrjs-cover.png `
] ,
2024-09-07 20:56:08 +02:00
creator : "@SVR_JS"
}
} ;
}
const ContactLayout = ( { children } : { children : React.ReactNode } ) = > {
return < > { children } < / > ;
} ;
export default ContactLayout ;