mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-06-28 12:16:53 +00:00
update
This commit is contained in:
parent
09c84d4a3e
commit
3695a28b97
@ -56,15 +56,15 @@
|
|||||||
body {
|
body {
|
||||||
@apply bg-background text-foreground;
|
@apply bg-background text-foreground;
|
||||||
}
|
}
|
||||||
hr {
|
|
||||||
@apply my-8 border-t border-gray-300;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@layer utilities {
|
/* Custom styles for code blocks */
|
||||||
.text-balance {
|
.prose pre {
|
||||||
text-wrap: balance;
|
background-color: #f3f4f6;
|
||||||
}
|
color: #1f2937;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.prose code {
|
||||||
|
color: #1f2937;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
"use client"
|
|
||||||
|
|
||||||
import type React from "react"
|
|
||||||
import CopyableCode from "@/components/CopyableCode"
|
|
||||||
|
|
||||||
function processContent(content: string): React.ReactNode[] {
|
|
||||||
const parts = content.split(/(```[\s\S]*?```|`[^`\n]+`)/g)
|
|
||||||
return parts.map((part, index) => {
|
|
||||||
if (part.startsWith("```") && part.endsWith("```")) {
|
|
||||||
const code = part.slice(3, -3).trim()
|
|
||||||
return <CopyableCode key={index} code={code} />
|
|
||||||
} 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>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return <span key={index} dangerouslySetInnerHTML={{ __html: part }} />
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function GuideContent({ content }: { content: string }) {
|
|
||||||
const processedContent = processContent(content)
|
|
||||||
|
|
||||||
return (
|
|
||||||
<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}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
@ -2,71 +2,32 @@ import fs from "fs"
|
|||||||
import path from "path"
|
import path from "path"
|
||||||
import { remark } from "remark"
|
import { remark } from "remark"
|
||||||
import html from "remark-html"
|
import html from "remark-html"
|
||||||
import dynamic from "next/dynamic"
|
|
||||||
|
|
||||||
const CopyableCode = dynamic(() => import("@/components/CopyableCode"), { ssr: false })
|
|
||||||
|
|
||||||
const guidesDirectory = path.join(process.cwd(), "..", "guides")
|
|
||||||
|
|
||||||
async function getGuideContent(slug: string) {
|
async function getGuideContent(slug: string) {
|
||||||
const fullPath = path.join(guidesDirectory, `${slug}.md`)
|
const guidePath = path.join(process.cwd(), "..", "guides", `${slug}.md`)
|
||||||
try {
|
const fileContents = fs.readFileSync(guidePath, "utf8")
|
||||||
const fileContents = fs.readFileSync(fullPath, "utf8")
|
|
||||||
const result = await remark().use(html).process(fileContents)
|
const result = await remark().use(html).process(fileContents)
|
||||||
return result.toString()
|
return result.toString()
|
||||||
} catch (error) {
|
|
||||||
console.error(`Error reading guide file: ${fullPath}`, error)
|
|
||||||
return "<p>Guide content not found.</p>"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function generateStaticParams() {
|
export async function generateStaticParams() {
|
||||||
try {
|
const guideFiles = fs.readdirSync(path.join(process.cwd(), "..", "guides"))
|
||||||
if (fs.existsSync(guidesDirectory)) {
|
|
||||||
const guideFiles = fs.readdirSync(guidesDirectory)
|
|
||||||
return guideFiles.map((file) => ({
|
return guideFiles.map((file) => ({
|
||||||
slug: file.replace(/\.md$/, ""),
|
slug: file.replace(/\.md$/, ""),
|
||||||
}))
|
}))
|
||||||
} else {
|
|
||||||
console.warn("Guides directory not found. No static params generated.")
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error generating static params for guides:", error)
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function wrapCodeBlocksWithCopyable(content: string) {
|
|
||||||
const codeBlockRegex = /<pre><code>([\s\S]*?)<\/code><\/pre>/g
|
|
||||||
return content.replace(codeBlockRegex, (match, code) => {
|
|
||||||
return `<CopyableCode code={\`${code.replace(/`/g, "\\`")}\`} />`
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function GuidePage({ params }: { params: { slug: string } }) {
|
export default async function GuidePage({ params }: { params: { slug: string } }) {
|
||||||
let guideContent = await getGuideContent(params.slug)
|
const guideContent = await getGuideContent(params.slug)
|
||||||
guideContent = wrapCodeBlocksWithCopyable(guideContent)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-white">
|
<div className="container mx-auto px-4 py-16 max-w-3xl bg-white text-gray-900">
|
||||||
<div className="container mx-auto px-4 py-16 max-w-3xl">
|
|
||||||
<div
|
<div
|
||||||
className="prose prose-gray max-w-none
|
className="prose prose-lg prose-gray max-w-none prose-pre:bg-gray-100 prose-pre:text-gray-900"
|
||||||
[&>h1]:text-3xl [&>h1]:font-bold [&>h1]:text-gray-900 [&>h1]:mb-6
|
|
||||||
[&>h2]:text-2xl [&>h2]:font-semibold [&>h2]:text-gray-900 [&>h2]:mt-8 [&>h2]:mb-4
|
|
||||||
[&>h3]:text-xl [&>h3]:font-semibold [&>h3]:text-gray-900 [&>h3]:mt-6 [&>h3]:mb-3
|
|
||||||
[&>p]:text-gray-700 [&>p]:mb-4
|
|
||||||
[&>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"
|
|
||||||
dangerouslySetInnerHTML={{ __html: guideContent }}
|
dangerouslySetInnerHTML={{ __html: guideContent }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user