Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit b3e9142

Browse files
committed
build fix
1 parent 37262dd commit b3e9142

3 files changed

Lines changed: 23 additions & 39 deletions

File tree

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from "react"
2+
import { Light as BaseSyntaxHighlighter } from "react-syntax-highlighter"
3+
import lua from "react-syntax-highlighter/dist/esm/languages/prism/lua"
4+
import theme from "react-syntax-highlighter/dist/esm/styles/hljs/docco"
5+
6+
BaseSyntaxHighlighter.registerLanguage("lua", lua)
7+
8+
type Props = React.ComponentProps<typeof BaseSyntaxHighlighter>
9+
10+
const SyntaxHighlighter: React.FC<Props> = (props) => {
11+
return <BaseSyntaxHighlighter style={theme} {...props} />
12+
}
13+
14+
export default SyntaxHighlighter
15+
16+

src/pages/pkg.tsx

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ import Footer from "@/components/footer"
1414
import { Button } from "@/components/ui/button"
1515
import { Input } from "@/components/ui/input"
1616
import { 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

2320
export 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(/language-([a-z0-9]+)/i) || className.match(/lang-([a-z0-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 = /language-|lang-/.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

Comments
 (0)