@@ -14,11 +14,8 @@ import Footer from "@/components/footer"
1414import { Button } from "@/components/ui/button"
1515import { Input } from "@/components/ui/input"
1616import { Skeleton } from "@/components/ui/skeleton"
17- import { Light as SyntaxHighlighter } from 'react-syntax-highlighter' ;
18- import lua from 'react-syntax-highlighter/dist/esm/languages/hljs/lua' ; // or prism/lua
19- import docco from 'react-syntax-highlighter/dist/esm/styles/hljs/docco' ; // Example style
20-
21- SyntaxHighlighter . registerLanguage ( 'lua' , lua ) ;
17+ import dynamic from "next/dynamic"
18+ const SyntaxHighlighter = dynamic ( ( ) => import ( "@/components/LuaSyntaxHighlighter" ) , { ssr : false } )
2219
2320export default function PackageView ( ) {
2421 const [ pkg , setPackage ] = useState < Package > ( )
@@ -234,35 +231,6 @@ export default function PackageView() {
234231 < Markdown
235232 options = { {
236233 disableParsingRawHTML : true ,
237- overrides : {
238- pre : {
239- component : ( { children, ...props } ) => {
240- const child = Array . isArray ( children ) ? children [ 0 ] : children
241- const className = child ?. props ?. className || ""
242- const match = ( className . match ( / l a n g u a g e - ( [ a - z 0 - 9 ] + ) / i) || className . match ( / l a n g - ( [ a - z 0 - 9 ] + ) / i) )
243- const language = match ? match [ 1 ] : 'lua'
244- const codeString = child ?. props ?. children || ''
245- return (
246- < SyntaxHighlighter
247- language = { language }
248- style = { docco }
249- // customStyle={{ paddingTop: "8px", paddingBottom: "8px", borderRadius: "10px" }}
250- >
251- { typeof codeString === 'string' ? codeString : String ( codeString ) }
252- </ SyntaxHighlighter >
253- )
254- }
255- } ,
256- code : {
257- component : ( { children, className, ...props } ) => {
258- const hasLanguage = / l a n g u a g e - | l a n g - / . test ( className || '' )
259- if ( hasLanguage ) {
260- return < code { ...props } className = { className } > { children } </ code >
261- }
262- return < code { ...props } className = "bg-[#f6f6f6] px-1.5 py-0.5 rounded text-sm" > { children } </ code >
263- }
264- }
265- }
266234 } }
267235 className = "markdown overflow-scroll" >
268236 { Buffer . from ( pkg ?. Readme || "" , 'hex' ) . toString ( ) . trim ( ) }
@@ -287,7 +255,7 @@ export default function PackageView() {
287255 else return "... ? ..."
288256 }()}
289257 </code> */ }
290- < SyntaxHighlighter language = "lua" style = { docco } customStyle = { { paddingTop : "8px" , paddingBottom : "8px" , borderRadius : "10px" } } showLineNumbers >
258+ < SyntaxHighlighter language = "lua" showLineNumbers >
291259 { function ( ) {
292260 if ( pkg ?. Source ) return ( Buffer . from ( pkg ?. Source || "" , 'hex' ) . toString ( ) ) . trim ( )
293261 else return "-- source code not found\n-- please contact the author"
0 commit comments