2024-07-22 11:49:47 +02:00
|
|
|
import clsx from "clsx";
|
|
|
|
|
import type { ComponentPropsWithoutRef, ElementType } from "react";
|
|
|
|
|
|
|
|
|
|
export function Prose<T extends ElementType = "div">({
|
|
|
|
|
as,
|
|
|
|
|
className,
|
|
|
|
|
...props
|
|
|
|
|
}: Omit<ComponentPropsWithoutRef<T>, "as" | "className"> & {
|
|
|
|
|
as?: T;
|
|
|
|
|
className?: string;
|
|
|
|
|
}) {
|
|
|
|
|
const Component = as ?? "div";
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Component
|
|
|
|
|
className={clsx(
|
|
|
|
|
className,
|
|
|
|
|
"prose dark:prose-invert",
|
|
|
|
|
// `html :where(& > *)` is used to select all direct children without an increase in specificity like you'd get from just `& > *`
|
2025-05-14 18:25:40 +02:00
|
|
|
"[html_:where(&>*)]:mx-auto [html_:where(&>*)]:max-w-2xl lg:[html_:where(&>*)]:mx-[calc(50%-min(50%,var(--container-lg)))] lg:[html_:where(&>*)]:max-w-3xl",
|
2024-07-22 11:49:47 +02:00
|
|
|
)}
|
|
|
|
|
{...props}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|