-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.tsx
More file actions
51 lines (47 loc) · 1.63 KB
/
index.tsx
File metadata and controls
51 lines (47 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { MDXProvider } from "@mdx-js/react";
import React from "react";
import { Blockquote } from "@/components/Blockquote";
import { Breadcrumb, Breadcrumbs } from "@/components/Breadcrumbs";
import { Code } from "@/components/Code";
import { Codeblock } from "@/components/Codeblock";
import { Heading } from "@/components/Heading";
import { Link } from "@/components/Link";
import { List } from "@/components/List";
import { Text } from "@/components/Text";
import { Application } from "@/layouts/Application";
import { classNames } from "@/lib/classNames";
export interface ArticleProps {
breadcrumbs?: Breadcrumb[];
children: React.ReactNode;
className?: string;
}
export function Article({ breadcrumbs = [], children, className }: ArticleProps) {
const hasBreadcrumbs = breadcrumbs && breadcrumbs.length > 0;
return (
<Application.Column>
<MDXProvider
components={{
a: Link,
blockquote: Blockquote,
code: Code,
h1: function h1(props: React.JSX.IntrinsicElements["h1"]) {
return <Heading el="h1" size="jumbo" {...props} />;
},
h2: function h2(props: React.JSX.IntrinsicElements["h2"]) {
return <Heading el="h2" size="l" {...props} />;
},
inlineCode: Code,
li: List.Item,
p: Text,
pre: Codeblock,
ul: List,
}}
>
<article className={classNames("AppArticle", className)}>
{hasBreadcrumbs && <Breadcrumbs className="AppArticle__Breadcrumbs" path={breadcrumbs} />}
{children}
</article>
</MDXProvider>
</Application.Column>
);
}