mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-06-15 14:28:21 +00:00
complete i18n migration to /[locale]/ with EN+ES content
Full rewrite of the docs site under app/[locale]/ with next-intl in localePrefix:"always" mode. Every page now exists at both /en/<path> and /es/<path>; the root / shows a meta-refresh + JS redirect to /<defaultLocale>/ so GitHub Pages serves something on the apex URL. Highlights: - 107 doc pages migrated to file-per-page JSON namespaces under messages/en/ and messages/es/. Spanish content is fully translated (no copy-of-English placeholders). - New documentation for the Active Suppressions section in the Settings tab and the per-event Dismiss dropdown in the Health Monitor modal. - New screenshots: dismiss-duration-dropdown.png and an updated health-suppression-settings.png. - Pagefind integrated for client-side search; index is built on every CI deploy (not committed). - RSS feeds: per-locale at /<locale>/rss.xml plus root /rss.xml for backward compat. - Removed the dead app/[locale]/guides/[slug]/ route — every guide now has its own static page and no markdown source remains. - Fixed orphan link /guides/nvidia -> /guides/nvidia-manual in docs/hardware/nvidia-host. - Removed obsolete components (footer2, calendar, drawer). Verified locally with `npm ci && npm run build`: 2804 files in out/, 231 pages indexed by pagefind, root redirect intact, both locale roots and the new Active Suppressions docs render OK.
This commit is contained in:
85
web/app/[locale]/docs/about/code-of-conduct/page.tsx
Normal file
85
web/app/[locale]/docs/about/code-of-conduct/page.tsx
Normal file
@@ -0,0 +1,85 @@
|
||||
import type { Metadata } from "next"
|
||||
import { getTranslations, setRequestLocale } from "next-intl/server"
|
||||
import fs from "fs"
|
||||
import path from "path"
|
||||
import { remark } from "remark"
|
||||
import html from "remark-html"
|
||||
import * as gfm from "remark-gfm"
|
||||
import React from "react"
|
||||
import parse from "html-react-parser"
|
||||
import CopyableCode from "@/components/CopyableCode"
|
||||
|
||||
export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }): Promise<Metadata> {
|
||||
const { locale } = await params
|
||||
const t = await getTranslations({ locale, namespace: "docs.about.codeOfConduct.meta" })
|
||||
return {
|
||||
title: t("title"),
|
||||
description: t("description"),
|
||||
openGraph: {
|
||||
title: t("ogTitle"),
|
||||
description: t("ogDescription"),
|
||||
type: "article",
|
||||
url: "https://macrimi.github.io/ProxMenux/docs/about/code-of-conduct",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
async function getCodeOfConductContent(notFoundMsg: string, loadFailedMsg: string) {
|
||||
try {
|
||||
const codeOfConductPath = path.join(process.cwd(), "..", "CODE_OF_CONDUCT.md")
|
||||
|
||||
if (!fs.existsSync(codeOfConductPath)) {
|
||||
console.error("CODE_OF_CONDUCT.md file not found.")
|
||||
return `<p class='text-red-600'>${notFoundMsg}</p>`
|
||||
}
|
||||
|
||||
const fileContents = fs.readFileSync(codeOfConductPath, "utf8")
|
||||
|
||||
const result = await remark()
|
||||
.use(gfm.default || gfm)
|
||||
.use(html)
|
||||
.process(fileContents)
|
||||
|
||||
return result.toString()
|
||||
} catch (error) {
|
||||
console.error("Error reading the CODE_OF_CONDUCT.md file", error)
|
||||
return `<p class='text-red-600'>${loadFailedMsg}</p>`
|
||||
}
|
||||
}
|
||||
|
||||
function cleanInlineCode(content: string) {
|
||||
return content.replace(/<code>(.*?)<\/code>/g, (_, codeContent) => {
|
||||
return `<code class="bg-gray-200 text-gray-900 px-1 rounded">${codeContent.replace(/^`|`$/g, "")}</code>`
|
||||
})
|
||||
}
|
||||
|
||||
function wrapCodeBlocksWithCopyable(content: string) {
|
||||
return parse(content, {
|
||||
replace: (domNode: any) => {
|
||||
if (domNode.name === "pre" && domNode.children.length > 0) {
|
||||
const codeElement = domNode.children.find((child: any) => child.name === "code")
|
||||
if (codeElement) {
|
||||
const codeContent = codeElement.children[0]?.data?.trim() || ""
|
||||
return <CopyableCode code={codeContent} />
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export default async function CodeOfConductPage({ params }: { params: Promise<{ locale: string }> }) {
|
||||
const { locale } = await params
|
||||
setRequestLocale(locale)
|
||||
const t = await getTranslations({ locale, namespace: "docs.about.codeOfConduct" })
|
||||
const codeOfConductContent = await getCodeOfConductContent(t("errors.notFound"), t("errors.loadFailed"))
|
||||
const cleanedInlineCode = cleanInlineCode(codeOfConductContent)
|
||||
const parsedContent = wrapCodeBlocksWithCopyable(cleanedInlineCode)
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-white text-gray-900">
|
||||
<div className="container mx-auto px-4 py-16" style={{ maxWidth: "980px" }}>
|
||||
<div className="prose max-w-none text-[16px]">{parsedContent}</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user