Skip to content

Commit

Permalink
add typography components for md rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
cansirin committed Dec 3, 2023
1 parent b93abaf commit 2316528
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
8 changes: 6 additions & 2 deletions apps/kampus/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import { RelayEnvironmentProvider } from "~/features/relay/RelayEnvironmentProvi
import "./globals.css";

import { ThemeProvider } from "@kampus/ui";
import { cn } from "~/../../packages/ui/utils";

const inter = Inter({ subsets: ["latin"] });
const inter = Inter({ subsets: ["latin"], variable: "--font-sans" });

export const metadata = {
title: "kamp.us",
Expand All @@ -19,7 +20,10 @@ export const metadata = {
export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html lang="en">
<body className={inter.className}>
<body className={cn(
"min-h-screen bg-background font-sans antialiased",
inter.variable
)}>
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
<RelayEnvironmentProvider>{children}</RelayEnvironmentProvider>
<Toaster />
Expand Down
29 changes: 27 additions & 2 deletions apps/kampus/app/odin/mufredat/[[...lesson]]/OdinLesson.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ import { graphql, usePreloadedQuery } from "react-relay";
import { type SerializablePreloadedQuery } from "@kampus/relay";
import useSerializablePreloadedQuery from "@kampus/relay/use-serializable-preloaded-query";

import {
TypographyBlockquote,
TypographyH1,
TypographyH2,
TypographyH3,
TypographyH4,
TypographyInlineCode,
TypographyList,
TypographyP,
} from "~/../../packages/ui";
import { type OdinLessonQuery } from "~/app/odin/mufredat/[[...lesson]]/__generated__/OdinLessonQuery.graphql";

interface Props {
Expand Down Expand Up @@ -36,8 +46,23 @@ export const OdinLessonContainer = (props: Props) => {

return (
<>
{lesson?.title}
<Markdown>{lesson?.body.html}</Markdown>
<Markdown
components={{
h1: ({ ...props }) => <TypographyH1 {...props} />,
h2: ({ ...props }) => <TypographyH2 {...props} />,
h3: ({ ...props }) => <TypographyH3 {...props} />,
h4: ({ ...props }) => <TypographyH4 {...props} />,
p: ({ ...props }) => <TypographyP {...props} />,
a: ({ ...props }) => (
<a {...props} className="underline" target="_blank" rel="noopener noreferrer" />
),
blockquote: ({ ...props }) => <TypographyBlockquote {...props} />,
code: ({ ...props }) => <TypographyInlineCode {...props} />,
ul: ({ ...props }) => <TypographyList {...props} />,
}}
>
{lesson?.body.html}
</Markdown>
</>
);
};

0 comments on commit 2316528

Please sign in to comment.