diff --git a/app/components/Doc.tsx b/app/components/Doc.tsx index 60d5c7633..eab308320 100644 --- a/app/components/Doc.tsx +++ b/app/components/Doc.tsx @@ -7,6 +7,7 @@ import { DocTitle } from '~/components/DocTitle' import { Markdown } from '~/components/Markdown' import { Toc } from './Toc' import { twMerge } from 'tailwind-merge' +import { TocMobile } from './TocMobile' type DocProps = { title: string @@ -89,55 +90,59 @@ export function Doc({ }, []) return ( -
+ + {shouldRenderToc ? : null}
- {title ? {title} : null} -
-
-
- -
-
-
-
- {title} : null} +
+
+
+ +
+
+ +
-
-
- {isTocVisible && ( -
- -
- )} -
+ {isTocVisible && ( +
+ +
+ )} +
+ ) } diff --git a/app/components/DocContainer.tsx b/app/components/DocContainer.tsx index 7f2566469..62260beec 100644 --- a/app/components/DocContainer.tsx +++ b/app/components/DocContainer.tsx @@ -9,7 +9,7 @@ export function DocContainer({
diff --git a/app/components/TocMobile.tsx b/app/components/TocMobile.tsx new file mode 100644 index 000000000..eb3caf4a5 --- /dev/null +++ b/app/components/TocMobile.tsx @@ -0,0 +1,54 @@ +import React from 'react' +import { Link } from '@tanstack/react-router' +import type { HeadingData } from 'marked-gfm-heading-id' +import { FaCaretRight, FaCaretDown } from 'react-icons/fa6' + +interface TocMobileProps { + headings: Array +} + +export function TocMobile({ headings }: TocMobileProps) { + const [isOpen, setIsOpen] = React.useState(false) + + const handleToggle = (event: React.SyntheticEvent) => { + setIsOpen(event.currentTarget.open) + } + + if (headings.length === 0) { + return null + } + + return ( +
+
+ + {isOpen ? : } + On this page + +
+
    + {headings.map((heading) => ( +
  • + ]+(>|$)/g, '')} + /> +
  • + ))} +
+
+
+
+ ) +} diff --git a/app/routes/_libraries/blog.$.tsx b/app/routes/_libraries/blog.$.tsx index d0a9bdf4e..e0bdc4e7c 100644 --- a/app/routes/_libraries/blog.$.tsx +++ b/app/routes/_libraries/blog.$.tsx @@ -82,7 +82,7 @@ ${content}` return ( -
+