-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: updated all slug folder & metadata
- Loading branch information
Showing
5 changed files
with
140 additions
and
283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 26 additions & 64 deletions
90
app/(docs)/guides/[...slug]/page.tsx → app/(docs)/guides/[slug]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { allPages } from "contentlayer/generated"; | ||
import { notFound } from "next/navigation"; | ||
|
||
import { Mdx } from "@/components/content/mdx-components"; | ||
|
||
import "@/styles/mdx.css"; | ||
|
||
import { Metadata } from "next"; | ||
|
||
import { constructMetadata } from "@/lib/utils"; | ||
|
||
export async function generateStaticParams() { | ||
return allPages.map((page) => ({ | ||
slug: page.slugAsParams, | ||
})); | ||
} | ||
|
||
export async function generateMetadata({ | ||
params, | ||
}: { | ||
params: { slug: string }; | ||
}): Promise<Metadata | undefined> { | ||
const page = allPages.find((page) => page.slugAsParams === params.slug); | ||
if (!page) { | ||
return; | ||
} | ||
|
||
const { title, description } = page; | ||
|
||
return constructMetadata({ | ||
title: `${title} – SaaS Starter`, | ||
description: description, | ||
}); | ||
} | ||
|
||
export default async function PagePage({ | ||
params, | ||
}: { | ||
params: { | ||
slug: string; | ||
}; | ||
}) { | ||
const page = allPages.find((page) => page.slugAsParams === params.slug); | ||
|
||
if (!page) { | ||
notFound(); | ||
} | ||
|
||
return ( | ||
<article className="container max-w-3xl py-6 lg:py-12"> | ||
<div className="space-y-4"> | ||
<h1 className="inline-block font-heading text-4xl lg:text-5xl"> | ||
{page.title} | ||
</h1> | ||
{page.description && ( | ||
<p className="text-xl text-muted-foreground">{page.description}</p> | ||
)} | ||
</div> | ||
<hr className="my-4" /> | ||
<Mdx code={page.body.code} /> | ||
</article> | ||
); | ||
} |
Oops, something went wrong.