mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2026-06-05 20:15:31 -04:00
5a1636baa3
- Replace Biome with oxlint + oxfmt (OXC toolchain) for linting and formatting - Add .oxlintrc.json and .oxfmtrc.json configuration files - Update VS Code settings and devcontainer to use oxc-vscode extension - Remove contact form, Resend email integration, and related server action/schema - Remove unused UI components (accordion, alert, card, tabs, toggle, etc.)
66 lines
2.1 KiB
TypeScript
66 lines
2.1 KiB
TypeScript
import type { MDXComponents } from "mdx/types";
|
|
import Image from "next/image";
|
|
import Link from "next/link";
|
|
|
|
import { CodeBlock } from "@/components/code-block";
|
|
import { ImageDiff } from "@/components/image-diff";
|
|
import { CodePen } from "@/components/third-party/codepen";
|
|
import { Gist } from "@/components/third-party/gist";
|
|
import { Tweet } from "@/components/third-party/tweet";
|
|
import { YouTube } from "@/components/third-party/youtube";
|
|
import { Video } from "@/components/video";
|
|
import { cn } from "@/lib/utils";
|
|
|
|
export const useMDXComponents = (components: MDXComponents): MDXComponents => {
|
|
return {
|
|
...components,
|
|
a: ({ href, rel, target, children, ...rest }: React.ComponentProps<typeof Link>) => {
|
|
const isExternal = typeof href === "string" && !["/", "#"].includes(href[0]);
|
|
if (isExternal) {
|
|
return (
|
|
<a href={href} rel={rel || "noopener noreferrer"} target={target || "_blank"} {...rest}>
|
|
{children}
|
|
</a>
|
|
);
|
|
}
|
|
return (
|
|
<Link href={href} rel={rel} target={target} {...rest}>
|
|
{children}
|
|
</Link>
|
|
);
|
|
},
|
|
pre: CodeBlock,
|
|
img: ({ src, alt, className, ...rest }: React.ComponentProps<typeof Image>) => {
|
|
const imageWidth =
|
|
typeof src === "object" && "width" in src && src.width > 896 ? 896 : undefined;
|
|
const imageHeight =
|
|
imageWidth && typeof src === "object" && "width" in src && "height" in src
|
|
? Math.round((src.height / src.width) * imageWidth)
|
|
: undefined;
|
|
|
|
return (
|
|
<Image
|
|
src={src}
|
|
alt={alt}
|
|
width={imageWidth}
|
|
height={imageHeight}
|
|
className={cn(
|
|
"mx-auto my-8 block h-auto max-w-full rounded-sm",
|
|
"[&+em]:text-muted-foreground [&+em]:-mt-4 [&+em]:block [&+em]:text-center [&+em]:text-[0.875em] [&+em]:leading-normal [&+em]:font-medium [&+em]:not-italic",
|
|
className,
|
|
)}
|
|
{...rest}
|
|
/>
|
|
);
|
|
},
|
|
|
|
// React components and embeds:
|
|
Video,
|
|
ImageDiff,
|
|
Tweet,
|
|
YouTube,
|
|
Gist,
|
|
CodePen,
|
|
};
|
|
};
|