From 986972a39948c8c97238496fa396eae53873a263 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Tue, 20 Aug 2024 23:41:54 +0200 Subject: [PATCH 1/2] simplifying --- src/app/[...slug]/page.tsx | 4 +- src/app/globals.css | 153 +---------------------------------- src/app/layout.tsx | 3 +- src/components/mdx/index.tsx | 132 ++++++++++++++++-------------- tailwind.config.ts | 8 ++ 5 files changed, 84 insertions(+), 216 deletions(-) diff --git a/src/app/[...slug]/page.tsx b/src/app/[...slug]/page.tsx index 4b70ff5d..2b9500e4 100644 --- a/src/app/[...slug]/page.tsx +++ b/src/app/[...slug]/page.tsx @@ -41,8 +41,8 @@ export default async function Page({ params }: Props) { return ( <>
-
-

{doc?.title}

+
+

{doc?.title}

{!!doc?.description?.length && (

{doc.description} diff --git a/src/app/globals.css b/src/app/globals.css index 487dd481..19898df4 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -13,26 +13,10 @@ body { font-optical-sizing: auto; } -pre, -code, -code span { - font-family: 'Inconsolata', monospace !important; -} - -/* Inline code */ -:not(pre) > code { - @apply bg-surface-container-high rounded-md px-1.5 py-0.5; -} - /* Start purging... */ @tailwind components; /* Stop purging. */ -/* Write your own custom component styles here */ -.btn-blue { - @apply bg-primary-container rounded px-4 py-2 font-bold; -} - /* Start purging... */ @tailwind utilities; /* Stop purging. */ @@ -50,127 +34,7 @@ code span { } .content-container :target { - /* 's h-16 + more spacing */ - scroll-margin-top: theme('spacing.20'); -} - -.content-container ul > li { - @apply my-2; -} - -.content-container ul > li:before { - content: '—'; - @apply mr-3 inline-block; -} - -.content-container :is(pre, code) { - @apply text-sm; -} - -.content-container pre { - @apply mb-8 overflow-hidden overflow-x-auto rounded p-4; -} - -main a { - @apply text-primary; -} - -.content-container .heading { - @apply block font-bold text-on-surface no-underline hover:underline; -} - -blockquote p { - @apply text-on-surface-variant/50; -} - -details { - @apply ml-4; -} - -summary { - @apply -ml-4 mb-2 cursor-pointer select-none; -} - -table { - @apply bg-surface-container-low; -} - -th { - @apply px-6 py-3 text-left text-xs font-medium uppercase tracking-wide; -} - -thead { - /* @apply bg-gray-50 dark:bg-gray-800; */ - @apply text-on-surface-variant/50; -} - -tbody tr:nth-child(even) { - /* @apply bg-white dark:bg-gray-900; */ - @apply bg-surface; -} - -tbody tr:nth-child(odd) { - /* @apply bg-gray-50 dark:bg-gray-800; */ -} - -td { - @apply px-6 py-4 text-sm; -} - -td:first-child { - @apply font-medium; -} - -ul.grid-list > li:before { - display: none; -} - -/* #intro-demos { - display: flex; - flex-flow: row nowrap; - justify-content: space-around; - align-items: center; - margin: 2em auto; - max-width: 900px; -} -#intro-demos .demo-cell { - padding-right: 10px; -} - -#intro-demos .demo-cell img.laptop { - max-width: 410px; -} - -#intro-demos .demo-cell img { - width: 100%; - margin-right: 10px; -} - -#intro-demos .demo-cell img.tablet { - max-width: 280px; -} - -#intro-demos .demo-cell img.phone { - max-width: 90px; -} - -.demo-grid { - grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); -} - -.demo-grid > div:last-of-type:nth-child(odd) { - grid-column: 1 / -1; -} */ - -.search-item.focus-visible li > div { - /* @apply bg-gray-800 text-gray-200; */ -} - -.hint p { - /* @apply dark:text-gray-500; */ -} -.hint p.mb-4:last-of-type { - margin-bottom: 0; + scroll-margin-top: theme('spacing.20'); /* 's h-16 + more spacing */ } /** @@ -182,23 +46,13 @@ ul.grid-list > li:before { code[class*='language-'], pre[class*='language-'] { background: none; - /* color: #e4f0fb; - text-shadow: 0 1px rgba(0, 0, 0, 0.3); */ - /* font-family: Menlo, Monaco, 'Courier New', monospace; */ text-align: left; white-space: pre; word-spacing: normal; word-break: normal; word-wrap: normal; line-height: 1.5; - - -moz-tab-size: 4; - -o-tab-size: 4; tab-size: 4; - - -webkit-hyphens: none; - -moz-hyphens: none; - -ms-hyphens: none; hyphens: none; } @@ -215,10 +69,7 @@ pre[class*='language-'] { --literal: #fffac2; --falsy: #f087bd; - @apply p-6; - @apply my-5; - @apply overflow-auto; - @apply rounded-lg; + @apply my-5 overflow-auto rounded-lg p-6 font-mono text-sm; } :not(pre) > code[class*='language-'], diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 68a53fed..005d3239 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,5 +1,5 @@ import type { Metadata } from 'next' -import { Inter } from 'next/font/google' +import { Inter, Inconsolata } from 'next/font/google' import './globals.css' import { svg } from '@/utils/icon' import resolveMdxUrl from '@/utils/resolveMdxUrl' @@ -7,6 +7,7 @@ import { ThemeProvider } from 'next-themes' import cn from '@/lib/cn' const inter = Inter({ subsets: ['latin'] }) +const inconsolata = Inconsolata({ subsets: ['latin'] }) const NEXT_PUBLIC_URL = process.env.NEXT_PUBLIC_URL const NEXT_PUBLIC_LIBNAME = process.env.NEXT_PUBLIC_LIBNAME diff --git a/src/components/mdx/index.tsx b/src/components/mdx/index.tsx index 48fdb8d4..987d86c0 100644 --- a/src/components/mdx/index.tsx +++ b/src/components/mdx/index.tsx @@ -1,91 +1,87 @@ import cn from '@/lib/cn' import { MARKDOWN_REGEX } from '@/utils/docs' -import { ComponentProps } from 'react' +import { ComponentProps, ReactNode } from 'react' export * from './Grid' export * from './Hint' -export const h2 = ({ children, id }: { children: React.ReactNode; id: string }) => ( - -

{children}

- +type Hn = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' +function Heading({ id, Tag, ...props }: { id: string; Tag: Hn } & ComponentProps) { + return ( + + + + ) +} +export const h2 = ({ id, ...props }: Omit, 'Tag'>) => ( + ) -export const h3 = ({ children, id }: { children: React.ReactNode; id: string }) => ( - -

{children}

-
+export const h3 = ({ id, ...props }: Omit, 'Tag'>) => ( + ) -export const h4 = ({ children, id }: { children: React.ReactNode; id: string }) => ( - -

{children}

-
+export const h4 = ({ id, ...props }: Omit, 'Tag'>) => ( + ) - -export const ul = ({ children }: { children: React.ReactNode }) => ( -
    {children}
+export const h5 = ({ id, ...props }: Omit, 'Tag'>) => ( + ) -export const ol = ({ children }: { children: React.ReactNode }) => ( -
    {children}
+export const h6 = ({ id, ...props }: Omit, 'Tag'>) => ( + ) -export const li = ({ children }: { children: React.ReactNode }) => ( + +export const ul = (props: ComponentProps<'ul'>) =>