EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
DocPage.jsx
Go to the documentation of this file.
1import { useParams } from 'react-router-dom';
2import DocsLayout from './DocsLayout';
3import { guides } from './guides/index';
4import { docGroups } from './docsData';
5
6function SectionRenderer({ section }) {
7 if (section.steps) {
8 return (
9 <ol className="step-list">
10 {section.steps.map((s, idx) => (
11 <li key={idx}>
12 <strong>{s.title}</strong>
13 <p>{s.text}</p>
14 </li>
15 ))}
16 </ol>
17 );
18 }
19 if (section.list) {
20 return (
21 <ul>
22 {section.list.map((li, idx) => (
23 <li key={idx}>{li}</li>
24 ))}
25 </ul>
26 );
27 }
28 if (section.links) {
29 return (
30 <ul className="doc-links">
31 {section.links.map((link, idx) => (
32 <li key={idx}>
33 <a href={link.url}>{link.title}</a>
34 </li>
35 ))}
36 </ul>
37 );
38 }
39}
40
41export default function DocPage() {
42 const { slug } = useParams();
43 let doc = guides.find((g) => g.slug === slug);
44 if (!doc) {
45 // Search docGroups for the slug if not found in guides
46 for (const group of docGroups) {
47 const found = group.items.find((i) => i.slug === slug);
48 if (found) {
49 doc = found;
50 break;
51 }
52 }
53 }
54
55 if (!doc) {
56 return (
57 <DocsLayout>
58 <section className="doc-section">
59 <h1>Not found</h1>
60 <p>The requested documentation page does not exist.</p>
61 </section>
62 </DocsLayout>
63 );
64 }
65
66 return (
67 <DocsLayout>
68 <section className="doc-section">
69 <h1>
70 <span className="material-symbols-outlined" style={{ verticalAlign: '-6px', marginRight: 8 }}>{doc.icon}</span>
71 {doc.title}
72 </h1>
73 {doc.summary && <p className="lead">{doc.summary}</p>}
74 {doc.image && (
75 <div className="doc-image-placeholder">
76 <img src={doc.image} alt={`${doc.title} preview`} onError={(e) => e.target.style.display = 'none'} />
77 </div>
78 )}
79 </section>
80
81 {doc.sections?.map((s, i) => (
82 <section className="doc-section" key={i}>
83 {s.heading && <h2>{s.heading}</h2>}
84 <SectionRenderer section={s} />
85 </section>
86 ))}
87 </DocsLayout>
88 );
89}