Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(web): enhance MDX with syntax highlighting and CapEmbed
Richie McIlroya19b18b6ba5e
diff --git a/apps/web/components/mdx.tsx b/apps/web/components/mdx.tsxindex ef9918ded..090d2f2ac 100644--- a/apps/web/components/mdx.tsx+++ b/apps/web/components/mdx.tsx@@ -2,6 +2,9 @@ import Image from "next/image";import Link from "next/link";import { MDXRemote } from "next-mdx-remote/rsc";import React, { type ReactNode } from "react";+import type { Options as RehypePrettyCodeOptions } from "rehype-pretty-code";+import rehypePrettyCode from "rehype-pretty-code";+import remarkGfm from "remark-gfm";interface TableData {headers: string[];@@ -105,6 +108,26 @@ function Warning(props: WarningProps) {);}+interface CapEmbedProps {+ src: string;+}++function CapEmbed({ src }: CapEmbedProps) {+ return (+ <iframe+ src={src}+ frameBorder="0"+ allowFullScreen+ style={{+ width: "100%",+ aspectRatio: "16 / 9",+ borderRadius: "15px",+ display: "block",+ }}+ />+ );+}+function slugify(str: string) {return str.toString()@@ -145,13 +168,25 @@ const components = {a: CustomLink,Callout,Warning,+ CapEmbed,Table,};+const rehypePrettyCodeOptions: RehypePrettyCodeOptions = {+ theme: "github-dark",+ keepBackground: true,+};+export function CustomMDX(props: any) {return (<MDXRemote{...props}+ options={{+ mdxOptions: {+ remarkPlugins: [remarkGfm],+ rehypePlugins: [[rehypePrettyCode, rehypePrettyCodeOptions]],+ },+ }}components={{ ...components, ...(props.components || {}) }}/>);diff --git a/apps/web/package.json b/apps/web/package.jsonindex af33d0316..f85284e61 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -129,10 +129,12 @@"react-scroll-parallax": "^3.4.5","react-tooltip": "^5.26.3","recharts": "^3.3.0",+ "rehype-pretty-code": "^0.14.1","remark-gfm": "^4.0.1","replicate": "^1.4.0","resend": "4.6.0","server-only": "^0.0.1",+ "shiki": "3","sonner": "^2.0.3","subtitles-parser-vtt": "^0.1.0","supermemory": "^4.11.1",