Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[www] Remove unnecessary mdx components customization #1491

Merged
merged 1 commit into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"format": "biome format --write .",
"lint": "biome check .",
"fix": "biome lint . --apply",
"bump": "bun update -y @types/node @types/react @types/react-dom typescript turbo"
"bump": "bun update -y @types/node @types/react @types/react-dom typescript turbo",
"dev": "bun run --cwd packages/www dev"
},
"workspaces": ["packages/*"],
"devDependencies": {
Expand Down
17 changes: 1 addition & 16 deletions packages/www/src/mdx-components.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import type { MDXComponents } from "mdx/types";
import Link from "next/link";
import { type ComponentProps, isValidElement } from "react";
import { isValidElement } from "react";
import StaticCodeBlock from "./lib/StaticCodeBlock";

type HeadingTag = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
type HeadingComponentType = (props: ComponentProps<HeadingTag>) => JSX.Element;

const Heading = (Tag: HeadingTag): HeadingComponentType =>
function TargetComponent({ id, children, ...props }: ComponentProps<typeof Tag>) {
return <Tag {...props}>{children}</Tag>;
};

const CustomMDXComponents: MDXComponents = {
code: (props) => <code {...props} />,
a: ({ href, ...props }) => {
if (href?.startsWith("http")) {
return <a href={href} {...props} />;
Expand Down Expand Up @@ -41,12 +32,6 @@ const CustomMDXComponents: MDXComponents = {
{children}
</ol>
),
h1: Heading("h1"),
h2: Heading("h2"),
h3: Heading("h3"),
h4: Heading("h4"),
h5: Heading("h5"),
h6: Heading("h6"),
};

// This file is required to use MDX in `app` directory.
Expand Down