2026-03-25 13:27:25 +08:00
|
|
|
import { useEffect, useState } from 'react';
|
2026-03-25 13:20:58 +08:00
|
|
|
import { useParams } from 'react-router-dom';
|
|
|
|
|
import SEOHead from '../components/seo/SEOHead';
|
2026-03-25 13:27:25 +08:00
|
|
|
import { useLanguage } from '../contexts/LanguageContext';
|
|
|
|
|
import { loadContent, type ContentItem } from '../lib/content';
|
2026-03-25 13:20:58 +08:00
|
|
|
|
|
|
|
|
export default function DocDetailPage() {
|
|
|
|
|
const { slug } = useParams<{ slug: string }>();
|
2026-03-25 13:27:25 +08:00
|
|
|
const { language } = useLanguage();
|
|
|
|
|
const [content, setContent] = useState<ContentItem | null>(null);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (slug) {
|
|
|
|
|
loadContent('docs', language, slug)
|
|
|
|
|
.then(setContent)
|
|
|
|
|
.catch(() => setContent(null));
|
|
|
|
|
}
|
|
|
|
|
}, [slug, language]);
|
|
|
|
|
|
|
|
|
|
if (!content) {
|
|
|
|
|
return (
|
|
|
|
|
<div className="max-w-4xl mx-auto py-16 px-6">
|
|
|
|
|
<p className="text-gray-600">{language === 'en' ? 'Loading...' : '加载中...'}</p>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 13:20:58 +08:00
|
|
|
return (
|
|
|
|
|
<>
|
2026-03-25 13:27:25 +08:00
|
|
|
<SEOHead
|
|
|
|
|
title={content.meta.title}
|
|
|
|
|
description={content.meta.description}
|
|
|
|
|
path={`/docs/${slug}`}
|
|
|
|
|
/>
|
2026-03-25 13:20:58 +08:00
|
|
|
<div className="max-w-4xl mx-auto py-16 px-6">
|
2026-03-25 13:27:25 +08:00
|
|
|
<article
|
|
|
|
|
className="prose prose-gray max-w-none"
|
|
|
|
|
dangerouslySetInnerHTML={{ __html: content.html }}
|
|
|
|
|
/>
|
2026-03-25 13:20:58 +08:00
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|