import Link from "next/link"; import { notFound } from "next/navigation"; import { Header, Footer } from "@/components/Shell"; import guides from "@/shared/player-docs.json"; import styles from "./page.module.css"; export const metadata = { title: "Player docs" }; function inline(text: string) { return text .split(/(\*\*[^*]+\*\*|\[[^\]]+\]\(https:\/\/[^)]+\))/g) .map((part, index) => { if (part.startsWith("**")) return {part.slice(2, -2)}; const link = part.match(/^\[([^\]]+)\]\((https:\/\/[^)]+)\)$/); return link ? ( {link[1]} ) : ( part ); }); } function content(markdown: string) { return markdown.split(/\n\s*\n/).map((block, index) => { const heading = block.match(/^(#{1,3}) (.+)$/); if (heading) { const text = inline(heading[2]); return heading[1].length === 1 ? (
{inline(block.replace(/^> /gm, ""))}); const lines = block.split("\n"); if (lines.every((line) => /^[-*] /.test(line))) return (
{inline(block)}
; }); } export default async function Docs({ searchParams, }: { searchParams: Promise<{ page?: string }>; }) { const { page = "welcome" } = await searchParams; const guide = guides.find((item) => item.slug === page); if (!guide) notFound(); const index = guides.indexOf(guide); return ( <>