File tree Expand file tree Collapse file tree 7 files changed +61
-5
lines changed Expand file tree Collapse file tree 7 files changed +61
-5
lines changed Original file line number Diff line number Diff line change @@ -4,8 +4,14 @@ import { notFound } from "next/navigation";
44import { format } from "date-fns" ;
55import MDX from "@/components/MDX" ;
66import { H2 } from "@/packages/ui" ;
7+ import { Metadata } from "next" ;
78
8- function getDocParams ( slug : string ) {
9+ interface IProps {
10+ params : { slug : string [ ] } ;
11+ }
12+
13+ function getDocParams ( { params } : IProps ) {
14+ const slug = `/docs${ params . slug ? `/${ params . slug . join ( "/" ) } ` : "" } ` ;
915 const doc = allDocs . find ( ( doc ) => doc . url === slug ) ;
1016
1117 if ( ! doc ) {
@@ -15,9 +21,23 @@ function getDocParams(slug: string) {
1521 return doc ;
1622}
1723
18- export default function page ( { params } : { params : { slug : string [ ] } } ) {
19- const slug = `/docs${ params . slug ? `/${ params . slug . join ( "/" ) } ` : "" } ` ;
20- const doc = getDocParams ( slug ) ;
24+ export async function generateMetadata ( { params } : IProps ) : Promise < Metadata > {
25+ const doc = getDocParams ( { params } ) ;
26+
27+ if ( ! doc ) {
28+ return {
29+ title : "Not Found | Retro UI" ,
30+ } ;
31+ }
32+
33+ return {
34+ title : `${ doc . title } | Retro UI` ,
35+ description : doc . description
36+ } ;
37+ }
38+
39+ export default function page ( { params } : IProps ) {
40+ const doc = getDocParams ( { params } ) ;
2141
2242 if ( ! doc ) {
2343 return notFound ( ) ;
Original file line number Diff line number Diff line change 1- import { JoinNewsletter } from "@/components" ;
21import {
32 Accordion ,
43 Avatar ,
Original file line number Diff line number Diff line change 11import TopNav from "@/components/TopNav" ;
22import "./global.css" ;
33import { Archivo_Black , Share_Tech , Share_Tech_Mono } from "next/font/google" ;
4+ import { Metadata } from "next" ;
45
56const archivoBlack = Archivo_Black ( {
67 subsets : [ "latin" ] ,
@@ -20,6 +21,14 @@ const shareTechMono = Share_Tech_Mono({
2021 variable : "--font-mono" ,
2122} ) ;
2223
24+ export const metadata : Metadata = {
25+ title : "Retro Styled Tailwind UI Library | Retro UI" ,
26+ description : "RetroUI - Retro styled TailwindCSS component library for modern web apps." ,
27+ openGraph : {
28+ images : [ '/banner.png' ]
29+ }
30+ } ;
31+
2332export default function RootLayout ( {
2433 children,
2534} : {
Original file line number Diff line number Diff line change 1+ import type { MetadataRoute } from 'next'
2+
3+ export default function robots ( ) : MetadataRoute . Robots {
4+ return {
5+ rules : {
6+ userAgent : '*' ,
7+ allow : '/' ,
8+ } ,
9+ sitemap : 'https://retroui.dev/sitemap.xml' ,
10+ }
11+ }
Original file line number Diff line number Diff line change 1+ import { allDocs } from "@/.contentlayer/generated" ;
2+ import type { MetadataRoute } from "next" ;
3+
4+ export default function sitemap ( ) : MetadataRoute . Sitemap {
5+ return [
6+ {
7+ url : "https://retroui.dev" ,
8+ lastModified : new Date ( ) ,
9+ changeFrequency : "yearly" ,
10+ priority : 1 ,
11+ } ,
12+ ...allDocs . map ( ( doc ) => ( {
13+ url : `https://retroui.dev${ doc . url } ` ,
14+ lastModified : doc . lastUpdated ,
15+ } ) ) ,
16+ ] ;
17+ }
You can’t perform that action at this time.
0 commit comments