2025-02-15 11:53:47 +01:00
|
|
|
"use client"
|
|
|
|
|
2025-02-15 11:56:54 +01:00
|
|
|
import type React from "react"
|
2025-02-15 11:53:47 +01:00
|
|
|
import CopyableCode from "@/components/CopyableCode"
|
|
|
|
|
2025-02-15 11:56:54 +01:00
|
|
|
function processContent(content: string): React.ReactNode[] {
|
2025-02-15 12:14:13 +01:00
|
|
|
const parts = content.split(/(```[\s\S]*?```|`[^`\n]+`)/g)
|
2025-02-15 11:56:54 +01:00
|
|
|
return parts.map((part, index) => {
|
|
|
|
if (part.startsWith("```") && part.endsWith("```")) {
|
|
|
|
const code = part.slice(3, -3).trim()
|
|
|
|
return <CopyableCode key={index} code={code} />
|
2025-02-15 12:14:13 +01:00
|
|
|
} else if (part.startsWith("`") && part.endsWith("`")) {
|
|
|
|
return (
|
|
|
|
<code key={index} className="bg-gray-100 text-gray-800 px-1 rounded">
|
|
|
|
{part.slice(1, -1)}
|
|
|
|
</code>
|
|
|
|
)
|
2025-02-15 11:56:54 +01:00
|
|
|
}
|
2025-02-15 12:14:13 +01:00
|
|
|
return <span key={index} dangerouslySetInnerHTML={{ __html: part }} />
|
2025-02-15 11:53:47 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function GuideContent({ content }: { content: string }) {
|
2025-02-15 12:31:06 +01:00
|
|
|
const processedContent = processContent(content)
|
2025-02-15 11:53:47 +01:00
|
|
|
|
|
|
|
return (
|
2025-02-15 12:31:06 +01:00
|
|
|
<div
|
|
|
|
className="prose max-w-none text-gray-900
|
|
|
|
[&>h1]:text-3xl [&>h1]:font-bold [&>h1]:mb-6 [&>h1]:text-gray-900
|
|
|
|
[&>h2]:text-2xl [&>h2]:font-semibold [&>h2]:mt-8 [&>h2]:mb-4 [&>h2]:text-gray-900
|
|
|
|
[&>h3]:text-xl [&>h3]:font-semibold [&>h3]:mt-6 [&>h3]:mb-3 [&>h3]:text-gray-900
|
|
|
|
[&>p]:mb-4 [&>p]:text-gray-700
|
|
|
|
[&>ul]:list-disc [&>ul]:pl-5 [&>ul]:mb-4
|
|
|
|
[&>ul>li]:text-gray-700 [&>ul>li]:mb-2
|
|
|
|
[&>ol]:list-decimal [&>ol]:pl-5 [&>ol]:mb-4
|
|
|
|
[&>ol>li]:text-gray-700 [&>ol>li]:mb-2
|
|
|
|
[&>a]:text-blue-600 [&>a:hover]:underline
|
|
|
|
[&>strong]:font-bold [&>strong]:text-gray-900"
|
|
|
|
>
|
|
|
|
{processedContent}
|
2025-02-15 11:56:54 +01:00
|
|
|
</div>
|
2025-02-15 11:53:47 +01:00
|
|
|
)
|
|
|
|
}
|
2025-02-15 12:22:29 +01:00
|
|
|
|