From dcf6f69709176720199ea0e234852cc0dad3553f Mon Sep 17 00:00:00 2001 From: Marcus Reinhardt Date: Thu, 23 Jan 2025 16:46:17 +0100 Subject: [PATCH] add missing page header styling --- .../test-collection/components/stepper.mdx | 5 +++ .../docs/test-collection/components/table.mdx | 7 ++++ src/app/docs/[...slug]/page.tsx | 7 +++- src/collections.ts | 39 +++++++++++-------- src/components/data-table-builder.tsx | 4 +- src/components/table-builder.tsx | 9 ++++- src/mdx-components.tsx | 4 +- 7 files changed, 51 insertions(+), 24 deletions(-) diff --git a/content/docs/test-collection/components/stepper.mdx b/content/docs/test-collection/components/stepper.mdx index bc05fa9..51d4703 100644 --- a/content/docs/test-collection/components/stepper.mdx +++ b/content/docs/test-collection/components/stepper.mdx @@ -3,6 +3,7 @@ title: Stepper --- import { Preview } from "@/components/preview" +import { APIReference } from "renoun/components" ## Source @@ -37,3 +38,7 @@ The component uses + +## API Reference + + diff --git a/content/docs/test-collection/components/table.mdx b/content/docs/test-collection/components/table.mdx index b445798..20ad67c 100644 --- a/content/docs/test-collection/components/table.mdx +++ b/content/docs/test-collection/components/table.mdx @@ -3,6 +3,7 @@ title: Table --- import { Preview } from "@/components/preview" +import { APIReference } from "renoun/components" ## Source @@ -172,3 +173,9 @@ The component uses ]} /> + +## API Reference + + + + diff --git a/src/app/docs/[...slug]/page.tsx b/src/app/docs/[...slug]/page.tsx index 0254f99..53837a9 100644 --- a/src/app/docs/[...slug]/page.tsx +++ b/src/app/docs/[...slug]/page.tsx @@ -158,7 +158,12 @@ async function DirectoryContent({ source }: { source: EntryType }) { "w-full max-w-full", )} > -

{source.getTitle()}

+

+ {source.getTitle()} +

diff --git a/src/collections.ts b/src/collections.ts index 7e138d5..09f32cc 100644 --- a/src/collections.ts +++ b/src/collections.ts @@ -29,6 +29,8 @@ export const docSchema = { headings: headingSchema, } +export const allowedExtensions = ["mdx", "tsx", "ts"] + export const AriaDocsCollection = new Directory({ path: "content/docs/aria-docs", // base path is required, otherwise we can't build the correct slugs in the `generateStaticParams` @@ -38,6 +40,8 @@ export const AriaDocsCollection = new Directory({ docSchema, (path) => import(`@content/docs/aria-docs/${path}.mdx`), ), + tsx: withSchema((path) => import(`@content/docs/aria-docs/${path}.tsx`)), + ts: withSchema((path) => import(`@content/docs/aria-docs/${path}.ts`)), }, }) @@ -50,6 +54,8 @@ export const RenounDocsCollection = new Directory({ docSchema, (path) => import(`@content/docs/renoun-docs/${path}.mdx`), ), + tsx: withSchema((path) => import(`@content/docs/renoun-docs/${path}.tsx`)), + ts: withSchema((path) => import(`@content/docs/renoun-docs/${path}.ts`)), }, }) @@ -62,6 +68,12 @@ export const TestCollection = new Directory({ docSchema, (path) => import(`@content/docs/test-collection/${path}.mdx`), ), + tsx: withSchema( + (path) => import(`@content/docs/test-collection/${path}.tsx`), + ), + ts: withSchema( + (path) => import(`@content/docs/test-collection/${path}.ts`), + ), }, }) @@ -76,12 +88,10 @@ export type DirectoryType = Awaited< export async function getDirectoryContent(source: EntryType) { // first, try to get the file based on the given path - try { - return await CollectionInfo.getDirectory(source.getPathSegments()) - // eslint-disable-next-line @typescript-eslint/no-unused-vars - } catch (e: unknown) { - return null - } + + return await CollectionInfo.getDirectory(source.getPathSegments()).catch( + () => null, + ) } /** @@ -94,20 +104,15 @@ export async function getDirectoryContent(source: EntryType) { */ export async function getFileContent(source: EntryType) { // first, try to get the file based on the given path - try { - return await CollectionInfo.getFile(source.getPathSegments(), "mdx") - // eslint-disable-next-line @typescript-eslint/no-unused-vars - } catch (e: unknown) { - try { + + return await CollectionInfo.getFile(source.getPathSegments(), "mdx").catch( + async () => { return await CollectionInfo.getFile( [...source.getPathSegments(), "index"], "mdx", - ) - // eslint-disable-next-line @typescript-eslint/no-unused-vars - } catch (e: unknown) { - return null - } - } + ).catch(() => null) + }, + ) } /** diff --git a/src/components/data-table-builder.tsx b/src/components/data-table-builder.tsx index 2eac8a1..e566654 100644 --- a/src/components/data-table-builder.tsx +++ b/src/components/data-table-builder.tsx @@ -22,12 +22,12 @@ import { import { DataTableColumnHeader } from "./data-table-column-header" import { DataTablePagination } from "./data-table-pagination" -interface DataTableProps { +export interface DataTableProps { columns: { id: string; title: string }[] data: TData[] } -export default function DataTableBuilder({ +export function DataTableBuilder({ columns, data, }: DataTableProps) { diff --git a/src/components/table-builder.tsx b/src/components/table-builder.tsx index 676249c..a07f737 100644 --- a/src/components/table-builder.tsx +++ b/src/components/table-builder.tsx @@ -9,11 +9,16 @@ import { TableRow, } from "./ui/table" -export default function TableBuilder({ +export interface TableBuilderColumnProps { + title: string + options?: React.ComponentProps +} + +export function TableBuilder({ columns, data, }: { - columns: { title: string; options?: React.ComponentProps }[] + columns: TableBuilderColumnProps[] data: { value: ReactNode options?: React.ComponentProps diff --git a/src/mdx-components.tsx b/src/mdx-components.tsx index a9493ff..276f729 100644 --- a/src/mdx-components.tsx +++ b/src/mdx-components.tsx @@ -11,10 +11,10 @@ import { import { ExternalLinkIcon } from "lucide-react" import { CodeBlock, CodeInline } from "renoun/components" -import DataTableBuilder from "./components/data-table-builder" +import { DataTableBuilder } from "./components/data-table-builder" import MermaidWrapper from "./components/mermaid-wrapper" import RailroadWrapper from "./components/railroad-wrapper" -import TableBuilder from "./components/table-builder" +import { TableBuilder } from "./components/table-builder" import { Alert, AlertDescription, AlertTitle } from "./components/ui/alert" import { Stepper, StepperItem } from "./components/ui/stepper" import {