@@ -7,17 +7,41 @@ import {
77 DocsPage ,
88 DocsTitle ,
99} from "fumadocs-ui/page" ;
10+ import type { Metadata , ResolvingMetadata } from "next" ;
1011import { notFound } from "next/navigation" ;
12+ import { Article , WithContext } from "schema-dts" ;
1113
1214export default async function Page ( props : {
1315 params : Promise < { slug ?: string [ ] } > ;
1416} ) {
1517 const params = await props . params ;
1618 const page = source . getPage ( params . slug ) ;
19+ const owner = "javaistic" ;
20+ const repo = "javaistic" ;
21+
1722 if ( ! page ) notFound ( ) ;
1823
1924 const MDXContent = page . data . body ;
2025
26+ const jsonLd : WithContext < Article > = {
27+ "@context" : "https://schema.org" ,
28+ "@type" : "Article" ,
29+ headline : page . data . title ,
30+ description : page . data . description ,
31+ author : {
32+ "@type" : "Organization" ,
33+ name : "Javaistic" ,
34+ } ,
35+ publisher : {
36+ "@type" : "Organization" ,
37+ name : "Javaistic" ,
38+ } ,
39+ mainEntityOfPage : {
40+ "@type" : "WebPage" ,
41+ "@id" : `https://javaistic.vercel.app/docs/${ page . path } ` ,
42+ } ,
43+ } ;
44+
2145 return (
2246 < DocsPage
2347 toc = { page . data . toc }
@@ -31,6 +55,7 @@ export default async function Page(props: {
3155 < DocsDescription className = "mb-3" >
3256 { page . data . description }
3357 </ DocsDescription >
58+
3459 < DocsBody >
3560 < MDXContent
3661 components = { getMDXComponents ( {
@@ -39,6 +64,12 @@ export default async function Page(props: {
3964 } ) }
4065 />
4166 </ DocsBody >
67+ < script
68+ type = "application/ld+json"
69+ dangerouslySetInnerHTML = { {
70+ __html : JSON . stringify ( jsonLd ) . replace ( / < / g, "\\u003c" ) ,
71+ } }
72+ />
4273 </ DocsPage >
4374 ) ;
4475}
@@ -47,11 +78,19 @@ export async function generateStaticParams() {
4778 return source . generateParams ( ) ;
4879}
4980
50- export async function generateMetadata ( props : {
81+ type Props = {
5182 params : Promise < { slug ?: string [ ] } > ;
52- } ) {
53- const params = await props . params ;
54- const page = source . getPage ( params . slug ) ;
83+ searchParams : Promise < { [ key : string ] : string | string [ ] | undefined } > ;
84+ } ;
85+
86+ export async function generateMetadata (
87+ { params, searchParams } : Props ,
88+ parent : ResolvingMetadata ,
89+ ) : Promise < Metadata > {
90+ const { slug } = await params ;
91+
92+ const page = source . getPage ( slug ) ;
93+
5594 if ( ! page ) notFound ( ) ;
5695
5796 return {
@@ -60,7 +99,8 @@ export async function generateMetadata(props: {
6099 openGraph : {
61100 title : `${ page . data . title } - Javaistic` ,
62101 description : page . data . description ,
63- sitename : "Javaistic" ,
102+ siteName : "Javaistic" ,
103+ url : `https://javaistic.vercel.app/docs/${ page . path } ` ,
64104 images : `https://og-javaistic.vercel.app/og?title=${ page . data . title } ` ,
65105 } ,
66106 twitter : {
0 commit comments