feat: landpage customize.

This commit is contained in:
dongqi shen 2025-01-20 17:58:47 +08:00
parent 95744b7a73
commit 920ec8d7ec
13 changed files with 847 additions and 72 deletions

View file

@ -0,0 +1,107 @@
import { notFound } from "next/navigation"
import { allDocs } from "contentlayer/generated"
import { getTableOfContents } from "@/lib/toc"
import { Mdx } from "@/components/mdx-components"
import { DocsPageHeader } from "@/components/page-header"
import { DocsPager } from "@/components/pager"
import { DashboardTableOfContents } from "@/components/toc"
import "@/styles/mdx.css"
import { Metadata } from "next"
import { env } from "@/env.mjs"
import { absoluteUrl } from "@/lib/utils"
interface DocPageProps {
params: {
slug: string[]
}
}
async function getDocFromParams(params) {
const slug = params.slug?.join("/") || ""
const doc = allDocs.find((doc) => doc.slugAsParams === slug)
if (!doc) {
null
}
return doc
}
export async function generateMetadata({
params,
}: DocPageProps): Promise<Metadata> {
const doc = await getDocFromParams(params)
if (!doc) {
return {}
}
const url = env.NEXT_PUBLIC_APP_URL
const ogUrl = new URL(`${url}/api/og`)
ogUrl.searchParams.set("heading", doc.description ?? doc.title)
ogUrl.searchParams.set("type", "Documentation")
ogUrl.searchParams.set("mode", "dark")
return {
title: doc.title,
description: doc.description,
openGraph: {
title: doc.title,
description: doc.description,
type: "article",
url: absoluteUrl(doc.slug),
images: [
{
url: ogUrl.toString(),
width: 1200,
height: 630,
alt: doc.title,
},
],
},
twitter: {
card: "summary_large_image",
title: doc.title,
description: doc.description,
images: [ogUrl.toString()],
},
}
}
export async function generateStaticParams(): Promise<
DocPageProps["params"][]
> {
return allDocs.map((doc) => ({
slug: doc.slugAsParams.split("/"),
}))
}
export default async function DocPage({ params }: DocPageProps) {
const doc = await getDocFromParams(params)
if (!doc) {
notFound()
}
const toc = await getTableOfContents(doc.body.raw)
return (
<main className="relative py-6 lg:gap-10 lg:py-10 xl:grid xl:grid-cols-[1fr_300px]">
<div className="mx-auto w-full min-w-0">
<DocsPageHeader heading={doc.title} text={doc.description} />
<Mdx code={doc.body.code} />
<hr className="my-4 md:my-6" />
<DocsPager doc={doc} />
</div>
<div className="hidden text-sm xl:block">
<div className="sticky top-16 -mt-10 max-h-[calc(var(--vh)-4rem)] overflow-y-auto pt-10">
<DashboardTableOfContents toc={toc} />
</div>
</div>
</main>
)
}

View file

@ -0,0 +1,17 @@
import { docsConfig } from "@/config/docs"
import { DocsSidebarNav } from "@/components/sidebar-nav"
interface DocsLayoutProps {
children: React.ReactNode
}
export default function DocsLayout({ children }: DocsLayoutProps) {
return (
<div className="flex-1 md:grid md:grid-cols-[220px_1fr] md:gap-6 lg:grid-cols-[240px_1fr] lg:gap-10">
<aside className="fixed top-14 z-30 hidden h-[calc(100vh-3.5rem)] w-full shrink-0 overflow-y-auto border-r py-6 pr-2 md:sticky md:block lg:py-10">
<DocsSidebarNav items={docsConfig.sidebarNavGuide} />
</aside>
{children}
</div>
)
}

View file

@ -47,15 +47,14 @@ export default async function IndexPage() {
Follow along on Twitter
</Link>
<h1 className="font-heading text-3xl sm:text-5xl md:text-6xl lg:text-7xl">
Xpop: An open-source tool for instant text actions on Mac.
Xpop for Mac
</h1>
<p className="max-w-[42rem] leading-normal text-muted-foreground sm:text-xl sm:leading-8">
I&apos;m building a web app with Next.js 13 and open sourcing
everything. Follow along as we figure this out together.
Xpop is an open-source and free tool that instantly provides useful actions when you select text in any app.
</p>
<div className="space-x-4">
<Link href="/login" className={cn(buttonVariants({ size: "lg" }))}>
Get Started
<Link href="/" className={cn(buttonVariants({ size: "lg" }))}>
Download
</Link>
<Link
href={siteConfig.links.github}
@ -77,21 +76,19 @@ export default async function IndexPage() {
Features
</h2>
<p className="max-w-[85%] leading-normal text-muted-foreground sm:text-lg sm:leading-7">
This project is an experiment to see how a modern app, with features
like auth, subscriptions, API routes, and static pages would work in
Next.js 13 app dir.
Built in Swift, Xpop is a free, open-source MacOS app designed for simplicity and extensibility, featuring plugins, and AI functionality.
</p>
</div>
<div className="mx-auto grid justify-center gap-4 sm:grid-cols-2 md:max-w-[64rem] md:grid-cols-3">
<div className="relative overflow-hidden rounded-lg border bg-background p-2">
<div className="flex h-[180px] flex-col justify-between rounded-md p-6">
<svg viewBox="0 0 24 24" className="h-12 w-12 fill-current">
<path d="M11.572 0c-.176 0-.31.001-.358.007a19.76 19.76 0 0 1-.364.033C7.443.346 4.25 2.185 2.228 5.012a11.875 11.875 0 0 0-2.119 5.243c-.096.659-.108.854-.108 1.747s.012 1.089.108 1.748c.652 4.506 3.86 8.292 8.209 9.695.779.25 1.6.422 2.534.525.363.04 1.935.04 2.299 0 1.611-.178 2.977-.577 4.323-1.264.207-.106.247-.134.219-.158-.02-.013-.9-1.193-1.955-2.62l-1.919-2.592-2.404-3.558a338.739 338.739 0 0 0-2.422-3.556c-.009-.002-.018 1.579-.023 3.51-.007 3.38-.01 3.515-.052 3.595a.426.426 0 0 1-.206.214c-.075.037-.14.044-.495.044H7.81l-.108-.068a.438.438 0 0 1-.157-.171l-.05-.106.006-4.703.007-4.705.072-.092a.645.645 0 0 1 .174-.143c.096-.047.134-.051.54-.051.478 0 .558.018.682.154.035.038 1.337 1.999 2.895 4.361a10760.433 10760.433 0 0 0 4.735 7.17l1.9 2.879.096-.063a12.317 12.317 0 0 0 2.466-2.163 11.944 11.944 0 0 0 2.824-6.134c.096-.66.108-.854.108-1.748 0-.893-.012-1.088-.108-1.747-.652-4.506-3.859-8.292-8.208-9.695a12.597 12.597 0 0 0-2.499-.523A33.119 33.119 0 0 0 11.573 0zm4.069 7.217c.347 0 .408.005.486.047a.473.473 0 0 1 .237.277c.018.06.023 1.365.018 4.304l-.006 4.218-.744-1.14-.746-1.14v-3.066c0-1.982.01-3.097.023-3.15a.478.478 0 0 1 .233-.296c.096-.05.13-.054.5-.054z" />
<path d="M18.88 1.099Q17.78-.001 16.233 0H3.746Q2.198 0 1.099 1.099Q-.001 2.199 0 3.746v12.487q0 1.548 1.099 2.647q1.1 1.1 2.647 1.099H6.66q.285 0 .429-.02a.5.5 0 0 0 .286-.169q.143-.15.143-.435l-.007-.885q-.006-.846-.006-1.34l-.3.052q-.285.052-.721.046a5.6 5.6 0 0 1-.904-.091a2 2 0 0 1-.872-.39a1.65 1.65 0 0 1-.572-.8l-.13-.3a3.3 3.3 0 0 0-.41-.663q-.28-.364-.566-.494l-.09-.065a1 1 0 0 1-.17-.156a.7.7 0 0 1-.117-.182q-.039-.092.065-.15q.104-.06.378-.059l.26.04q.26.051.643.311a2.1 2.1 0 0 1 .631.677q.3.532.722.813q.423.28.852.28t.742-.065a2.6 2.6 0 0 0 .585-.196q.117-.871.637-1.34a9 9 0 0 1-1.333-.234a5.3 5.3 0 0 1-1.223-.507a3.5 3.5 0 0 1-1.047-.872q-.416-.52-.683-1.365q-.266-.846-.266-1.952q0-1.573 1.027-2.68q-.48-1.183.091-2.652q.378-.118 1.119.175t1.086.5q.345.21.553.352a9.2 9.2 0 0 1 2.497-.338q1.288 0 2.498.338l.494-.312a7 7 0 0 1 1.197-.572q.689-.26 1.054-.143q.585 1.47.103 2.653q1.028 1.105 1.028 2.68q0 1.106-.267 1.957q-.266.852-.689 1.366a3.7 3.7 0 0 1-1.053.865q-.63.351-1.223.507a9 9 0 0 1-1.333.235q.675.585.676 1.846v3.11q0 .22.065.357a.36.36 0 0 0 .208.189q.143.052.254.064q.111.014.318.013h2.914q1.548 0 2.647-1.099t1.099-2.647V3.746q0-1.548-1.1-2.647z"/>
</svg>
<div className="space-y-2">
<h3 className="font-bold">Next.js 13</h3>
<h3 className="font-bold">Open-Source</h3>
<p className="text-sm text-muted-foreground">
App dir, Routing, Layouts, Loading UI and API routes.
Free, Open-source, Collaborative, Customizable.
</p>
</div>
</div>
@ -99,12 +96,12 @@ export default async function IndexPage() {
<div className="relative overflow-hidden rounded-lg border bg-background p-2">
<div className="flex h-[180px] flex-col justify-between rounded-md p-6">
<svg viewBox="0 0 24 24" className="h-12 w-12 fill-current">
<path d="M14.23 12.004a2.236 2.236 0 0 1-2.235 2.236 2.236 2.236 0 0 1-2.236-2.236 2.236 2.236 0 0 1 2.235-2.236 2.236 2.236 0 0 1 2.236 2.236zm2.648-10.69c-1.346 0-3.107.96-4.888 2.622-1.78-1.653-3.542-2.602-4.887-2.602-.41 0-.783.093-1.106.278-1.375.793-1.683 3.264-.973 6.365C1.98 8.917 0 10.42 0 12.004c0 1.59 1.99 3.097 5.043 4.03-.704 3.113-.39 5.588.988 6.38.32.187.69.275 1.102.275 1.345 0 3.107-.96 4.888-2.624 1.78 1.654 3.542 2.603 4.887 2.603.41 0 .783-.09 1.106-.275 1.374-.792 1.683-3.263.973-6.365C22.02 15.096 24 13.59 24 12.004c0-1.59-1.99-3.097-5.043-4.032.704-3.11.39-5.587-.988-6.38a2.167 2.167 0 0 0-1.092-.278zm-.005 1.09v.006c.225 0 .406.044.558.127.666.382.955 1.835.73 3.704-.054.46-.142.945-.25 1.44a23.476 23.476 0 0 0-3.107-.534A23.892 23.892 0 0 0 12.769 4.7c1.592-1.48 3.087-2.292 4.105-2.295zm-9.77.02c1.012 0 2.514.808 4.11 2.28-.686.72-1.37 1.537-2.02 2.442a22.73 22.73 0 0 0-3.113.538 15.02 15.02 0 0 1-.254-1.42c-.23-1.868.054-3.32.714-3.707.19-.09.4-.127.563-.132zm4.882 3.05c.455.468.91.992 1.36 1.564-.44-.02-.89-.034-1.345-.034-.46 0-.915.01-1.36.034.44-.572.895-1.096 1.345-1.565zM12 8.1c.74 0 1.477.034 2.202.093.406.582.802 1.203 1.183 1.86.372.64.71 1.29 1.018 1.946-.308.655-.646 1.31-1.013 1.95-.38.66-.773 1.288-1.18 1.87a25.64 25.64 0 0 1-4.412.005 26.64 26.64 0 0 1-1.183-1.86c-.372-.64-.71-1.29-1.018-1.946a25.17 25.17 0 0 1 1.013-1.954c.38-.66.773-1.286 1.18-1.868A25.245 25.245 0 0 1 12 8.098zm-3.635.254c-.24.377-.48.763-.704 1.16-.225.39-.435.782-.635 1.174-.265-.656-.49-1.31-.676-1.947.64-.15 1.315-.283 2.015-.386zm7.26 0c.695.103 1.365.23 2.006.387-.18.632-.405 1.282-.66 1.933a25.952 25.952 0 0 0-1.345-2.32zm3.063.675c.484.15.944.317 1.375.498 1.732.74 2.852 1.708 2.852 2.476-.005.768-1.125 1.74-2.857 2.475-.42.18-.88.342-1.355.493a23.966 23.966 0 0 0-1.1-2.98c.45-1.017.81-2.01 1.085-2.964zm-13.395.004c.278.96.645 1.957 1.1 2.98a23.142 23.142 0 0 0-1.086 2.964c-.484-.15-.944-.318-1.37-.5-1.732-.737-2.852-1.706-2.852-2.474 0-.768 1.12-1.742 2.852-2.476.42-.18.88-.342 1.356-.494zm11.678 4.28c.265.657.49 1.312.676 1.948-.64.157-1.316.29-2.016.39a25.819 25.819 0 0 0 1.341-2.338zm-9.945.02c.2.392.41.783.64 1.175.23.39.465.772.705 1.143a22.005 22.005 0 0 1-2.006-.386c.18-.63.406-1.282.66-1.933zM17.92 16.32c.112.493.2.968.254 1.423.23 1.868-.054 3.32-.714 3.708-.147.09-.338.128-.563.128-1.012 0-2.514-.807-4.11-2.28.686-.72 1.37-1.536 2.02-2.44 1.107-.118 2.154-.3 3.113-.54zm-11.83.01c.96.234 2.006.415 3.107.532.66.905 1.345 1.727 2.035 2.446-1.595 1.483-3.092 2.295-4.11 2.295a1.185 1.185 0 0 1-.553-.132c-.666-.38-.955-1.834-.73-3.703.054-.46.142-.944.25-1.438zm4.56.64c.44.02.89.034 1.345.034.46 0 .915-.01 1.36-.034-.44.572-.895 1.095-1.345 1.565-.455-.47-.91-.993-1.36-1.565z" />
<path d="M11 1a3 3 0 0 0-3 3H2v6a3 3 0 1 1 0 6v6h6a3 3 0 1 1 6 0h6v-6a3 3 0 1 0 0-6V4h-6a3 3 0 0 0-3-3"/>
</svg>
<div className="space-y-2">
<h3 className="font-bold">React 18</h3>
<p className="text-sm">
Server and Client Components. Use hook.
<h3 className="font-bold">Extensibility</h3>
<p className="text-sm text-muted-foreground">
Extension system, partially compatible with PopClip extensions.<sup><a href="#footnote-1" id="ref-1">1</a></sup>
</p>
</div>
</div>
@ -112,67 +109,24 @@ export default async function IndexPage() {
<div className="relative overflow-hidden rounded-lg border bg-background p-2">
<div className="flex h-[180px] flex-col justify-between rounded-md p-6">
<svg viewBox="0 0 24 24" className="h-12 w-12 fill-current">
<path d="M0 12C0 5.373 5.373 0 12 0c4.873 0 9.067 2.904 10.947 7.077l-15.87 15.87a11.981 11.981 0 0 1-1.935-1.099L14.99 12H12l-8.485 8.485A11.962 11.962 0 0 1 0 12Zm12.004 12L24 12.004C23.998 18.628 18.628 23.998 12.004 24Z" />
<path d="m12.594 23.258l-.012.002l-.071.035l-.02.004l-.014-.004l-.071-.036q-.016-.004-.024.006l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.016-.018m.264-.113l-.014.002l-.184.093l-.01.01l-.003.011l.018.43l.005.012l.008.008l.201.092q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.003-.011l.018-.43l-.003-.012l-.01-.01z"/><path d="M9.107 5.448c.598-1.75 3.016-1.803 3.725-.159l.06.16l.807 2.36a4 4 0 0 0 2.276 2.411l.217.081l2.36.806c1.75.598 1.803 3.016.16 3.725l-.16.06l-2.36.807a4 4 0 0 0-2.412 2.276l-.081.216l-.806 2.361c-.598 1.75-3.016 1.803-3.724.16l-.062-.16l-.806-2.36a4 4 0 0 0-2.276-2.412l-.216-.081l-2.36-.806c-1.751-.598-1.804-3.016-.16-3.724l.16-.062l2.36-.806A4 4 0 0 0 8.22 8.025l.081-.216zM11 6.094l-.806 2.36a6 6 0 0 1-3.49 3.649l-.25.091l-2.36.806l2.36.806a6 6 0 0 1 3.649 3.49l.091.25l.806 2.36l.806-2.36a6 6 0 0 1 3.49-3.649l.25-.09l2.36-.807l-2.36-.806a6 6 0 0 1-3.649-3.49l-.09-.25zM19 2a1 1 0 0 1 .898.56l.048.117l.35 1.026l1.027.35a1 1 0 0 1 .118 1.845l-.118.048l-1.026.35l-.35 1.027a1 1 0 0 1-1.845.117l-.048-.117l-.35-1.026l-1.027-.35a1 1 0 0 1-.118-1.845l.118-.048l1.026-.35l.35-1.027A1 1 0 0 1 19 2"/>
</svg>
<div className="space-y-2">
<h3 className="font-bold">Database</h3>
<h3 className="font-bold">AI Powered</h3>
<p className="text-sm text-muted-foreground">
ORM using Prisma and deployed on PlanetScale.
</p>
</div>
</div>
</div>
<div className="relative overflow-hidden rounded-lg border bg-background p-2">
<div className="flex h-[180px] flex-col justify-between rounded-md p-6">
<svg viewBox="0 0 24 24" className="h-12 w-12 fill-current">
<path d="M12.001 4.8c-3.2 0-5.2 1.6-6 4.8 1.2-1.6 2.6-2.2 4.2-1.8.913.228 1.565.89 2.288 1.624C13.666 10.618 15.027 12 18.001 12c3.2 0 5.2-1.6 6-4.8-1.2 1.6-2.6 2.2-4.2 1.8-.913-.228-1.565-.89-2.288-1.624C16.337 6.182 14.976 4.8 12.001 4.8zm-6 7.2c-3.2 0-5.2 1.6-6 4.8 1.2-1.6 2.6-2.2 4.2-1.8.913.228 1.565.89 2.288 1.624 1.177 1.194 2.538 2.576 5.512 2.576 3.2 0 5.2-1.6 6-4.8-1.2 1.6-2.6 2.2-4.2 1.8-.913-.228-1.565-.89-2.288-1.624C10.337 13.382 8.976 12 6.001 12z" />
</svg>
<div className="space-y-2">
<h3 className="font-bold">Components</h3>
<p className="text-sm text-muted-foreground">
UI components built using Radix UI and styled with Tailwind
CSS.
</p>
</div>
</div>
</div>
<div className="relative overflow-hidden rounded-lg border bg-background p-2">
<div className="flex h-[180px] flex-col justify-between rounded-md p-6">
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1"
className="h-12 w-12 fill-current"
>
<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"></path>
</svg>
<div className="space-y-2">
<h3 className="font-bold">Authentication</h3>
<p className="text-sm text-muted-foreground">
Authentication using NextAuth.js and middlewares.
</p>
</div>
</div>
</div>
<div className="relative overflow-hidden rounded-lg border bg-background p-2">
<div className="flex h-[180px] flex-col justify-between rounded-md p-6">
<svg viewBox="0 0 24 24" className="h-12 w-12 fill-current">
<path d="M13.976 9.15c-2.172-.806-3.356-1.426-3.356-2.409 0-.831.683-1.305 1.901-1.305 2.227 0 4.515.858 6.09 1.631l.89-5.494C18.252.975 15.697 0 12.165 0 9.667 0 7.589.654 6.104 1.872 4.56 3.147 3.757 4.992 3.757 7.218c0 4.039 2.467 5.76 6.476 7.219 2.585.92 3.445 1.574 3.445 2.583 0 .98-.84 1.545-2.354 1.545-1.875 0-4.965-.921-6.99-2.109l-.9 5.555C5.175 22.99 8.385 24 11.714 24c2.641 0 4.843-.624 6.328-1.813 1.664-1.305 2.525-3.236 2.525-5.732 0-4.128-2.524-5.851-6.594-7.305h.003z" />
</svg>
<div className="space-y-2">
<h3 className="font-bold">Subscriptions</h3>
<p className="text-sm text-muted-foreground">
Free and paid subscriptions using Stripe.
Built-In AI: Translating, Writing, Grammar, Beyond.
</p>
</div>
</div>
</div>
</div>
<div className="mx-auto text-center md:max-w-[58rem]">
<p className="leading-normal text-muted-foreground sm:text-lg sm:leading-7">
Taxonomy also includes a blog and a full-featured documentation site
built using Contentlayer and MDX.
<div className="mx-auto text-center max-w-4xl">
<p id="footnote-1" className="text-sm text-gray-600">
<sup className="text-xs text-gray-500">1</sup>
PopClip is an exceptional product with powerful and well-developed plugin functionality.
I will strive to ensure compatibility with more of its plugins in the future. Stay tuned!
<a href="#ref-1" className="text-blue-500 hover:text-blue-700"></a>
</p>
</div>
</section>

View file

@ -2,9 +2,13 @@ import { DocsConfig } from "types"
export const docsConfig: DocsConfig = {
mainNav: [
// {
// title: "Guides",
// href: "/guides",
// },
{
title: "Guides",
href: "/guides",
title: "Guide",
href: "/guide",
},
{
title: "Reference",
@ -133,4 +137,126 @@ export const docsConfig: DocsConfig = {
],
},
],
sidebarNavGuide: [
{
title: "Getting Started",
items: [
{
title: "Introduction",
href: "/guide",
},
],
},
{
title: "Documentation",
items: [
{
title: "Introduction",
href: "/guide/documentation",
},
{
title: "Contentlayer",
href: "/guide/in-progress",
disabled: true,
},
{
title: "Components",
href: "/guide/documentation/components",
},
{
title: "Code Blocks",
href: "/guide/documentation/code-blocks",
},
{
title: "Style Guide",
href: "/guide/documentation/style-guide",
},
{
title: "Search",
href: "/guide/in-progress",
disabled: true,
},
],
},
{
title: "Blog",
items: [
{
title: "Introduction",
href: "/guide/in-progress",
disabled: true,
},
{
title: "Build your own",
href: "/guide/in-progress",
disabled: true,
},
{
title: "Writing Posts",
href: "/guide/in-progress",
disabled: true,
},
],
},
{
title: "Dashboard",
items: [
{
title: "Introduction",
href: "/guide/in-progress",
disabled: true,
},
{
title: "Layouts",
href: "/guide/in-progress",
disabled: true,
},
{
title: "Server Components",
href: "/guide/in-progress",
disabled: true,
},
{
title: "Authentication",
href: "/guide/in-progress",
disabled: true,
},
{
title: "Database with Prisma",
href: "/guide/in-progress",
disabled: true,
},
{
title: "API Routes",
href: "/guide/in-progress",
disabled: true,
},
],
},
{
title: "Marketing Site",
items: [
{
title: "Introduction",
href: "/guide/in-progress",
disabled: true,
},
{
title: "File Structure",
href: "/guide/in-progress",
disabled: true,
},
{
title: "Tailwind CSS",
href: "/guide/in-progress",
disabled: true,
},
{
title: "Typography",
href: "/guide/in-progress",
disabled: true,
},
],
},
],
}

View file

@ -12,7 +12,7 @@ export const marketingConfig: MarketingConfig = {
// },
{
title: "Guide",
href: "/guides",
href: "/guide",
},
// {
// title: "Blog",

View file

@ -8,6 +8,6 @@ export const siteConfig: SiteConfig = {
ogImage: "https://tx.shadcn.com/og.jpg",
links: {
twitter: "https://x.com/corgi_shum",
github: "https://github.com/DongqiShen/Xpop",
github: "https://github.com/DongqiShen/taxonomy",
},
}

View file

@ -0,0 +1,73 @@
---
title: Code Blocks
description: Advanced code blocks with highlighting, file names and more.
---
The code blocks on the documentation site and the blog are powered by [rehype-pretty-code](https://github.com/atomiks/rehype-pretty-code). The syntax highlighting is done using [shiki](https://github.com/shikijs/shiki).
It has the following features:
1. Beautiful code blocks with syntax highlighting.
2. Support for VS Code themes.
3. Works with hundreds of languages.
4. Line and word highlighting.
5. Support for line numbers.
6. Show code block titles using meta strings.
<Callout>
Thanks to Shiki, highlighting is done at build time. No JavaScript is sent to the client for runtime highlighting.
</Callout>
## Example
```ts showLineNumbers title="next.config.js" {3} /appDir: true/
import { withContentlayer } from "next-contentlayer"
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
images: {
domains: ["avatars.githubusercontent.com"],
},
experimental: {
appDir: true,
serverComponentsExternalPackages: ["@prisma/client"],
},
}
export default withContentlayer(nextConfig)
```
## Title
````mdx
```ts title="path/to/file.ts"
// Code here
```
````
## Line Highlight
````mdx
```ts {1,3-6}
// Highlight line 1 and line 3 to 6
```
````
## Word Highlight
````mdx
```ts /shadcn/
// Highlight the word shadcn.
```
````
## Line Numbers
````mdx
```ts showLineNumbers
// This will show line numbers.
```
````

View file

@ -0,0 +1,157 @@
---
title: Components
description: Use React components in Markdown using MDX.
---
The following components are available out of the box for use in Markdown.
If you'd like to build and add your own custom components, see the [Custom Components](#custom-components) section below.
## Built-in Components
### 1. Callout
```mdx
<Callout type=" default | warning | danger ">
This is a default callout. You can embed **Markdown** inside a `callout`.
</Callout>
```
<Callout>
This is a default callout. You can embed **Markdown** inside a `callout`.
</Callout>
<Callout type="warning">
This is a warning callout. It uses the props `type="warning"`.
</Callout>
<Callout type="danger">
This is a danger callout. It uses the props `type="danger"`.
</Callout>
### 2. Card
```mdx
<Card href="#">
#### Heading
You can use **markdown** inside cards.
</Card>
```
<Card href="#">
#### Heading
You can use **markdown** inside cards.
</Card>
You can also use HTML to embed cards in a grid.
```mdx
<div className="grid grid-cols-2 gap-4">
<Card href="#">
#### Card One
You can use **markdown** inside cards.
</Card>
<Card href="#">
#### Card Two
You can also use `inline code` and code blocks.
</Card>
</div>
```
<div className="grid grid-cols-2 gap-4">
<Card href="#">
#### Card One
You can use **markdown** inside cards.
</Card>
<Card href="#">
#### Card Two
You can also use `inline code` and code blocks.
</Card>
</div>
---
## Custom Components
You can add your own custom components using the `components` props from `useMDXComponent`.
```ts title="components/mdx.tsx" {2,6}
import { Callout } from "@/components/callout"
import { CustomComponent } from "@/components/custom"
const components = {
Callout,
CustomComponent,
}
export function Mdx({ code }) {
const Component = useMDXComponent(code)
return (
<div className="mdx">
<Component components={components} />
</div>
)
}
```
Once you've added your custom component, you can use it in MDX as follows:
```js
<CustomComponent propName="value" />
```
---
## HTML Elements
You can overwrite HTML elements using the same technique above.
```ts {4}
const components = {
Callout,
CustomComponent,
hr: ({ ...props }) => <hr className="my-4 border-slate-200 md:my-6" />,
}
```
This will overwrite the `<hr />` tag or `---` in Mardown with the HTML output above.
---
## Styling
Tailwind CSS classes can be used inside MDX for styling.
```mdx
<p className="text-red-600">This text will be red.</p>
```
Make sure you have configured the path to your content in your `tailwind.config.js` file:
```js title="tailwind.config.js" {6}
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./app/**/*.{ts,tsx}",
"./components/**/*.{ts,tsx}",
"./content/**/*.{md,mdx}",
],
}
```

View file

@ -0,0 +1,60 @@
---
title: Documentation
description: Build your documentation site using Contentlayer and MDX.
---
Taxonomy includes a documentation site built using [Contentlayer](https://contentlayer.dev) and [MDX](http://mdxjs.com).
## Features
It comes with the following features out of the box:
1. Write content using MDX.
2. Transform and validate content using Contentlayer.
3. MDX components such as `<Callout />` and `<Card />`.
4. Support for table of contents.
5. Custom navigation with prev and next pager.
6. Beautiful code blocks using `rehype-pretty-code`.
7. Syntax highlighting using `shiki`.
8. Built-in search (_in progress_).
9. Dark mode (_in progress_).
## How is it built
Click on a section below to learn how the documentation site built.
<div className="grid gap-4 mt-6">
<Card href="/docs/documentation">
### Contentlayer
Learn how to use MDX with Contentlayer.
</Card>
<Card href="/docs/documentation/components">
### Components
Using React components in Mardown.
</Card>
<Card href="/docs/documentation/components">
### Code Blocks
Beautiful code blocks with syntax highlighting.
</Card>
<Card href="/docs/documentation/components">
### Style Guide
View a sample page with all the styles.
</Card>
</div>

View file

@ -0,0 +1,216 @@
---
title: Style Guide
description: Testing the MDX style guide with Tailwind Typography
---
<Callout>
- The text below is from the [Tailwind CSS](https://play.tailwindcss.com/uj1vGACRJA?layout=preview) docs. I copied it here to test the markdown styles. **Tailwind is awesome. You should use it.**
- The CSS is from MDX sites I've built through the years. I copied this from [Nextra](https://github.com/shuding/nextra) and tweaked it a bit to fit the styles of this site.
</Callout>
Until now, trying to style an article, document, or blog post with Tailwind has been a tedious task that required a keen eye for typography and a lot of complex custom CSS.
By default, Tailwind removes all of the default browser styling from paragraphs, headings, lists and more. This ends up being really useful for building application UIs because you spend less time undoing user-agent styles, but when you _really are_ just trying to style some content that came from a rich-text editor in a CMS or a markdown file, it can be surprising and unintuitive.
We get lots of complaints about it actually, with people regularly asking us things like:
> Why is Tailwind removing the default styles on my `h1` elements? How do I disable this? What do you mean I lose all the other base styles too?
> We hear you, but we're not convinced that simply disabling our base styles is what you really want. You don't want to have to remove annoying margins every time you use a `p` element in a piece of your dashboard UI. And I doubt you really want your blog posts to use the user-agent styles either — you want them to look _awesome_, not awful.
The `@tailwindcss/typography` plugin is our attempt to give you what you _actually_ want, without any of the downsides of doing something stupid like disabling our base styles.
It adds a new `prose` class that you can slap on any block of vanilla HTML content and turn it into a beautiful, well-formatted document:
```html
<article class="prose">
<h1>Garlic bread with cheese: What the science tells us</h1>
<p>
For years parents have espoused the health benefits of eating garlic bread
with cheese to their children, with the food earning such an iconic status
in our culture that kids will often dress up as warm, cheesy loaf for
Halloween.
</p>
<p>
But a recent study shows that the celebrated appetizer may be linked to a
series of rabies cases springing up around the country.
</p>
</article>
```
For more information about how to use the plugin and the features it includes, [read the documentation](https://github.com/tailwindcss/typography/blob/master/README.md).
---
## What to expect from here on out
What follows from here is just a bunch of absolute nonsense I've written to dogfood the plugin itself. It includes every sensible typographic element I could think of, like **bold text**, unordered lists, ordered lists, code blocks, block quotes, _and even italics_.
It's important to cover all of these use cases for a few reasons:
1. We want everything to look good out of the box.
2. Really just the first reason, that's the whole point of the plugin.
3. Here's a third pretend reason though a list with three items looks more realistic than a list with two items.
Now we're going to try out another header style.
### Typography should be easy
So that's a header for you — with any luck if we've done our job correctly that will look pretty reasonable.
Something a wise person once told me about typography is:
> Typography is pretty important if you don't want your stuff to look like trash. Make it good then it won't be bad.
It's probably important that images look okay here by default as well:
<Image
src="/images/blog/blog-post-4.jpg"
width="718"
height="404"
alt="Image"
/>
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.
Now I'm going to show you an example of an unordered list to make sure that looks good, too:
- So here is the first item in this list.
- In this example we're keeping the items short.
- Later, we'll use longer, more complex list items.
And that's the end of this section.
## What if we stack headings?
### We should make sure that looks good, too.
Sometimes you have headings directly underneath each other. In those cases you often have to undo the top margin on the second heading because it usually looks better for the headings to be closer together than a paragraph followed by a heading should be.
### When a heading comes after a paragraph …
When a heading comes after a paragraph, we need a bit more space, like I already mentioned above. Now let's see what a more complex list would look like.
- **I often do this thing where list items have headings.**
For some reason I think this looks cool which is unfortunate because it's pretty annoying to get the styles right.
I often have two or three paragraphs in these list items, too, so the hard part is getting the spacing between the paragraphs, list item heading, and separate list items to all make sense. Pretty tough honestly, you could make a strong argument that you just shouldn't write this way.
- **Since this is a list, I need at least two items.**
I explained what I'm doing already in the previous list item, but a list wouldn't be a list if it only had one item, and we really want this to look realistic. That's why I've added this second list item so I actually have something to look at when writing the styles.
- **It's not a bad idea to add a third item either.**
I think it probably would've been fine to just use two items but three is definitely not worse, and since I seem to be having no trouble making up arbitrary things to type, I might as well include it.
After this sort of list I usually have a closing statement or paragraph, because it kinda looks weird jumping right to a heading.
## Code should look okay by default.
I think most people are going to use [highlight.js](https://highlightjs.org/) or [Prism](https://prismjs.com/) or something if they want to style their code blocks but it wouldn't hurt to make them look _okay_ out of the box, even with no syntax highlighting.
Here's what a default `tailwind.config.js` file looks like at the time of writing:
```js
module.exports = {
purge: [],
theme: {
extend: {},
},
variants: {},
plugins: [],
}
```
Hopefully that looks good enough to you.
### What about nested lists?
Nested lists basically always look bad which is why editors like Medium don't even let you do it, but I guess since some of you goofballs are going to do it we have to carry the burden of at least making it work.
1. **Nested lists are rarely a good idea.**
- You might feel like you are being really "organized" or something but you are just creating a gross shape on the screen that is hard to read.
- Nested navigation in UIs is a bad idea too, keep things as flat as possible.
- Nesting tons of folders in your source code is also not helpful.
2. **Since we need to have more items, here's another one.**
- I'm not sure if we'll bother styling more than two levels deep.
- Two is already too much, three is guaranteed to be a bad idea.
- If you nest four levels deep you belong in prison.
3. **Two items isn't really a list, three is good though.**
- Again please don't nest lists if you want people to actually read your content.
- Nobody wants to look at this.
- I'm upset that we even have to bother styling this.
The most annoying thing about lists in Markdown is that `<li>` elements aren't given a child `<p>` tag unless there are multiple paragraphs in the list item. That means I have to worry about styling that annoying situation too.
- **For example, here's another nested list.**
But this time with a second paragraph.
- These list items won't have `<p>` tags
- Because they are only one line each
- **But in this second top-level list item, they will.**
This is especially annoying because of the spacing on this paragraph.
- As you can see here, because I've added a second line, this list item now has a `<p>` tag.
This is the second line I'm talking about by the way.
- Finally here's another list item so it's more like a list.
- A closing list item, but with no nested list, because why not?
And finally a sentence to close off this section.
## There are other elements we need to style
I almost forgot to mention links, like [this link to the Tailwind CSS website](https://tailwindcss.com). We almost made them blue but that's so yesterday, so we went with dark gray, feels edgier.
We even included table styles, check it out:
| Wrestler | Origin | Finisher |
| ----------------------- | ------------ | ------------------ |
| Bret "The Hitman" Hart | Calgary, AB | Sharpshooter |
| Stone Cold Steve Austin | Austin, TX | Stone Cold Stunner |
| Randy Savage | Sarasota, FL | Elbow Drop |
| Vader | Boulder, CO | Vader Bomb |
| Razor Ramon | Chuluota, FL | Razor's Edge |
We also need to make sure inline code looks good, like if I wanted to talk about `<span>` elements or tell you the good news about `@tailwindcss/typography`.
### Sometimes I even use `code` in headings
Even though it's probably a bad idea, and historically I've had a hard time making it look good. This _"wrap the code blocks in backticks"_ trick works pretty well though really.
Another thing I've done in the past is put a `code` tag inside of a link, like if I wanted to tell you about the [`tailwindcss/docs`](https://github.com/tailwindcss/docs) repository. I don't love that there is an underline below the backticks but it is absolutely not worth the madness it would require to avoid it.
#### We haven't used an `h4` yet
But now we have. Please don't use `h5` or `h6` in your content, Medium only supports two heading levels for a reason, you animals. I honestly considered using a `before` pseudo-element to scream at you if you use an `h5` or `h6`.
We don't style them at all out of the box because `h4` elements are already so small that they are the same size as the body copy. What are we supposed to do with an `h5`, make it _smaller_ than the body copy? No thanks.
### We still need to think about stacked headings though.
#### Let's make sure we don't screw that up with `h4` elements, either.
Phew, with any luck we have styled the headings above this text and they look pretty good.
Let's add a closing paragraph here so things end with a decently sized block of text. I can't explain why I want things to end that way but I have to assume it's because I think things will look weird or unbalanced if there is a heading too close to the end of the document.
What I've written here is probably long enough, but adding this final sentence can't hurt.
## GitHub Flavored Markdown
I've also added support for GitHub Flavored Mardown using `remark-gfm`.
With `remark-gfm`, we get a few extra features in our markdown. Example: autolink literals.
A link like www.example.com or https://example.com would automatically be converted into an `a` tag.
This works for email links too: contact@example.com.

View file

@ -0,0 +1,10 @@
---
title: Not Implemented
description: This page is in progress.
---
<Callout>
This site is a work in progress. If you see dummy text on a page, it means I'm still working on it. You can follow updates on Twitter [@shadcn](https://twitter.com/shadcn).
</Callout>

54
content/guide/index.mdx Normal file
View file

@ -0,0 +1,54 @@
---
title: Documentation
description: Welcome to the Taxonomy documentation.
---
This is the documentation for the Taxonomy site.
This is an example of a doc site built using [ContentLayer](/docs/documentation/contentlayer) and MDX.
<Callout>
This site is a work in progress. If you see dummy text on a page, it means I'm still working on it. You can follow updates on Twitter [@shadcn](https://twitter.com/shadcn).
</Callout>
## Features
Select a feature below to learn more about it.
<div className="grid sm:grid-cols-2 gap-4 mt-6">
<Card href="/docs/documentation">
### Documentation
This documentation site built using Contentlayer.
</Card>
<Card href="/docs/marketing" disabled>
### Marketing
The marketing site with landing pages.
</Card>
<Card href="/docs/app" disabled>
### App
The dashboard with auth and subscriptions.
</Card>
<Card href="/docs/blog" disabled>
### Blog
The blog built using Contentlayer and MDX.
</Card>
</div>

1
types/index.d.ts vendored
View file

@ -41,6 +41,7 @@ export type SiteConfig = {
export type DocsConfig = {
mainNav: MainNavItem[]
sidebarNav: SidebarNavItem[]
sidebarNavGuide: SidebarNavItem[]
}
export type MarketingConfig = {