diff --git a/app/components/docs/Table.tsx b/app/components/docs/Table.tsx new file mode 100644 index 0000000..1bebb38 --- /dev/null +++ b/app/components/docs/Table.tsx @@ -0,0 +1,45 @@ +import type { ComponentPropsWithoutRef } from 'react' + +export default function Table({ + columns, + rows, + footnotes, + ...props +}: ComponentPropsWithoutRef<'table'> & { + columns: string[] + rows: string[][] + footnotes: string[] +}) { + return ( + <> + + + + {columns.map((column, i) => ( + + ))} + + + + {rows.map((row, i) => ( + + {row.map((cell, j) => ( + + ))} + + ))} + +
{column}
{cell}
+ {footnotes.length > 0 && ( +
    + {footnotes.map((footnote, i) => ( +
  1. + {i + 1} + {footnote} +
  2. + ))} +
+ )} + + ) +} diff --git a/app/components/layout/Content.tsx b/app/components/layout/Content.tsx index 451988d..0d3924c 100644 --- a/app/components/layout/Content.tsx +++ b/app/components/layout/Content.tsx @@ -30,6 +30,7 @@ import { import Ref from '~/components/docs/Ref.tsx' import { RoleVar } from '~/components/docs/RoleVar.tsx' import { ChildHeading, TableLink } from '~/components/docs/Spec.tsx' +import Table from '~/components/docs/Table.tsx' import Tag from '~/components/docs/Tag.tsx' import ErrorPage from '~/components/layout/ErrorPage.tsx' import TableOfContents from '~/components/layout/TableOfContents.tsx' @@ -42,7 +43,7 @@ import { CACHE_CONTROL } from '~/utils/http.server.ts' import { removeEndSlashes } from '~/utils/removeEndSlashes.ts' export async function publicLoader({ params }: LoaderFunctionArgs) { - let { product, ref, '*': splat } = params + const { product, ref, '*': splat } = params invariant(product, 'expected `params.product`') invariant(ref, 'expected `params.ref`') @@ -83,7 +84,7 @@ export async function publicLoader({ params }: LoaderFunctionArgs) { } export async function privateLoader({ params }: LoaderFunctionArgs) { - let { product, ref, '*': splat } = params + const { product, ref, '*': splat } = params invariant(product, 'expected `params.product`') invariant(ref, 'expected `params.ref`') @@ -125,8 +126,9 @@ export async function privateLoader({ params }: LoaderFunctionArgs) { } export const headers: HeadersFunction = ({ loaderHeaders }) => { + const cacheControl = loaderHeaders.get('Cache-Control') ?? CACHE_CONTROL.doc return { - 'Cache-Control': loaderHeaders.get('Cache-Control')!, + 'Cache-Control': cacheControl, 'Vary': 'Cookie', } } @@ -223,6 +225,7 @@ export function Content({ TableLink, Image, CopyButton, + Table, Tag, Ref, MediaRow, @@ -279,7 +282,6 @@ export function Content({ export function ErrorBoundary() { const error = useRouteError() - console.log(error) let status = 500 let message = 'Unknown error' diff --git a/app/lib/docs/mdx/index.server.ts b/app/lib/docs/mdx/index.server.ts index 10fe894..5f90b1e 100644 --- a/app/lib/docs/mdx/index.server.ts +++ b/app/lib/docs/mdx/index.server.ts @@ -1,4 +1,5 @@ import { bundleMDX } from 'mdx-bundler' +import path from 'path' import rehypeAutolinkHeadings from 'rehype-autolink-headings' import rehypeSlug from 'rehype-slug' import remarkGfm from 'remark-gfm' @@ -15,9 +16,10 @@ import rehypeWrapTable from './tables.server.ts' export async function parseMdx(mdx: string) { // Pull all h2 & h3 headings - let headings: Heading[] = [] + const headings: Heading[] = [] const { frontmatter, code } = await bundleMDX({ source: mdx, + cwd: path.join(process.cwd(), 'documentation'), mdxOptions(options) { options.remarkPlugins = [ ...(options.remarkPlugins ?? []), diff --git a/package-lock.json b/package-lock.json index 5e09530..047d701 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5528,11 +5528,11 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -8733,9 +8733,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -10627,9 +10627,9 @@ } }, "node_modules/jsdom/node_modules/ws": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", - "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", "dev": true, "engines": { "node": ">=10.0.0" @@ -17919,9 +17919,9 @@ "dev": true }, "node_modules/ws": { - "version": "7.5.9", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", - "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "version": "7.5.10", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", + "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", "engines": { "node": ">=8.3.0" },