mirror of
https://github.com/LukeHagar/jsdoc-cheatsheet.git
synced 2025-12-07 20:47:46 +00:00
feat: add react-syntax-highlighter and update JSDoc cheatsheet layout
Integrate react-syntax-highlighter for improved code example rendering and enhance the JSDoc cheatsheet layout with a new navigation structure and quick reference section.
This commit is contained in:
46
components/SyntaxHighlighter.tsx
Normal file
46
components/SyntaxHighlighter.tsx
Normal file
@@ -0,0 +1,46 @@
|
||||
"use client"
|
||||
|
||||
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'
|
||||
import { vscDarkPlus } from 'react-syntax-highlighter/dist/esm/styles/prism'
|
||||
|
||||
interface SyntaxHighlighterProps {
|
||||
code: string
|
||||
language?: string
|
||||
}
|
||||
|
||||
const CodeHighlighter = ({ code, language = "javascript" }: SyntaxHighlighterProps) => {
|
||||
return (
|
||||
<div className="rounded-lg overflow-hidden border border-slate-700">
|
||||
<SyntaxHighlighter
|
||||
language={language}
|
||||
style={vscDarkPlus}
|
||||
customStyle={{
|
||||
background: '#0f172a',
|
||||
borderRadius: '0.5rem',
|
||||
fontSize: '0.875rem',
|
||||
lineHeight: '1.6',
|
||||
border: 'none',
|
||||
margin: 0,
|
||||
padding: '1rem',
|
||||
}}
|
||||
codeTagProps={{
|
||||
style: {
|
||||
fontFamily: 'ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace',
|
||||
}
|
||||
}}
|
||||
showLineNumbers={false}
|
||||
wrapLines={true}
|
||||
wrapLongLines={true}
|
||||
PreTag={({ children, ...props }) => (
|
||||
<pre className="!m-0 !p-0" {...props}>
|
||||
{children}
|
||||
</pre>
|
||||
)}
|
||||
>
|
||||
{code}
|
||||
</SyntaxHighlighter>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default CodeHighlighter
|
||||
Reference in New Issue
Block a user