diff --git a/components/StyledMarkdown.tsx b/components/StyledMarkdown.tsx index b25fff85f..a56cd48ee 100644 --- a/components/StyledMarkdown.tsx +++ b/components/StyledMarkdown.tsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import React, { useContext, useEffect, useState } from 'react'; import Markdown from 'markdown-to-jsx'; import Link from 'next/link'; import slugifyMarkdownHeadline from '~/lib/slugifyMarkdownHeadline'; @@ -8,6 +8,7 @@ import Highlight from 'react-syntax-highlighter'; import { atomOneDark } from 'react-syntax-highlighter/dist/cjs/styles/hljs'; import Code from '~/components/Code'; import { FullMarkdownContext } from '~/context'; +import Image from 'next/image'; import { Headline1, @@ -504,12 +505,24 @@ const StyledMarkdownBlock = ({ markdown }: { markdown: string }) => { const fullMarkdown = useContext(FullMarkdownContext); if (!fullMarkdown) return null; return ( -
- -
+ <> +
+ menu-icon + Table of Contents +
+
+ +
+ ); }, }, @@ -541,7 +554,7 @@ export function TableOfContentMarkdown({ href={`#${slug}`} className='block cursor-pointer mb-3 max-sm:text-sm text-slate-600 dark:text-slate-300 leading-4 ml-[-0.40rem] font-medium' > - + {children} @@ -570,12 +583,22 @@ export function TableOfContentMarkdown({ ? { component: ({ children }) => { const slug = slugifyMarkdownHeadline(children); + const [isChrome, setIsChrome] = useState(false); + + useEffect(() => { + const chromeCheck = + /Chrome/.test(navigator.userAgent) && + /Google Inc/.test(navigator.vendor); + setIsChrome(chromeCheck); + }, []); + return ( + // chromeClass - + {children} @@ -592,12 +615,12 @@ export function TableOfContentMarkdown({ return ( - - ● ● ● ● + + —— - + @@ -615,13 +638,12 @@ export function TableOfContentMarkdown({ return ( - - ● ● ● ● ● ● - ● ● ● ● ● + + ———— - + diff --git a/public/icons/toc-menu.svg b/public/icons/toc-menu.svg new file mode 100644 index 000000000..796ade803 --- /dev/null +++ b/public/icons/toc-menu.svg @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 8d5560f65..3e3772e64 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es2015", + "target": "ES2018", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true,