docs(trust-privacy): add comprehensive legitimate trust architecture and 12-article privacy policy with rich markdown rendering
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,45 +1,235 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import {
|
||||||
|
ShieldCheck,
|
||||||
|
CheckCircle2,
|
||||||
|
Lock,
|
||||||
|
Cpu,
|
||||||
|
Zap,
|
||||||
|
FileCheck,
|
||||||
|
AlertCircle,
|
||||||
|
ExternalLink,
|
||||||
|
ChevronRight
|
||||||
|
} from 'lucide-react';
|
||||||
|
|
||||||
interface RichTextSectionProps {
|
interface RichTextSectionProps {
|
||||||
markdown?: string;
|
markdown?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function RichTextSection({ markdown = '' }: RichTextSectionProps) {
|
export function RichTextSection({ markdown = '' }: RichTextSectionProps) {
|
||||||
// Simple, safe markdown to HTML parser for headers, lists, and paragraphs
|
// Helper to parse inline markdown (bold, italic, code, links)
|
||||||
const renderFormatted = (text: string) => {
|
const renderInline = (text: string): React.ReactNode[] => {
|
||||||
const lines = text.split('\n');
|
// Split on markdown tokens: **bold**, *italic*, `code`, [link](url)
|
||||||
return lines.map((line, idx) => {
|
const regex = /(\*\*.*?\*\*|\*.*?\*|`.*?`|\[.*?\]\(.*?\))/g;
|
||||||
if (line.startsWith('### ')) {
|
const parts = text.split(regex);
|
||||||
|
|
||||||
|
return parts.map((part, i) => {
|
||||||
|
if (!part) return null;
|
||||||
|
|
||||||
|
if (part.startsWith('**') && part.endsWith('**')) {
|
||||||
return (
|
return (
|
||||||
<h3 key={idx} className="text-xl font-bold text-slate-900 dark:text-white mt-6 mb-3">
|
<strong key={i} className="font-bold text-slate-900">
|
||||||
{line.replace('### ', '')}
|
{part.slice(2, -2)}
|
||||||
</h3>
|
</strong>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (line.startsWith('1. ') || line.startsWith('2. ') || line.startsWith('3. ') || line.startsWith('4. ')) {
|
if (part.startsWith('*') && part.endsWith('*')) {
|
||||||
return (
|
return (
|
||||||
<div key={idx} className="flex items-start space-x-2 my-2 text-sm text-slate-700 dark:text-slate-300">
|
<em key={i} className="italic text-slate-700">
|
||||||
<span className="font-bold text-blue-600">{line.slice(0, 3)}</span>
|
{part.slice(1, -1)}
|
||||||
<span>{line.slice(3)}</span>
|
</em>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (line.trim().length === 0) {
|
if (part.startsWith('`') && part.endsWith('`')) {
|
||||||
return <div key={idx} className="h-2" />;
|
return (
|
||||||
|
<code key={i} className="px-1.5 py-0.5 mx-0.5 rounded-md bg-slate-100 text-slate-800 font-mono text-xs border border-slate-200">
|
||||||
|
{part.slice(1, -1)}
|
||||||
|
</code>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return (
|
if (part.startsWith('[') && part.includes('](') && part.endsWith(')')) {
|
||||||
<p key={idx} className="text-sm text-slate-600 dark:text-slate-400 leading-relaxed my-2">
|
const linkMatch = part.match(/\[(.*?)\]\((.*?)\)/);
|
||||||
{line}
|
if (linkMatch) {
|
||||||
</p>
|
const [, linkText, linkHref] = linkMatch;
|
||||||
);
|
return (
|
||||||
|
<a
|
||||||
|
key={i}
|
||||||
|
href={linkHref}
|
||||||
|
className="text-accent font-semibold hover:underline inline-flex items-center gap-0.5"
|
||||||
|
>
|
||||||
|
<span>{linkText}</span>
|
||||||
|
{linkHref.startsWith('http') && <ExternalLink className="w-3 h-3 inline-block" />}
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return <React.Fragment key={i}>{part}</React.Fragment>;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const renderContent = (content: string) => {
|
||||||
|
const lines = content.split('\n');
|
||||||
|
const nodes: React.ReactNode[] = [];
|
||||||
|
let tableRows: string[][] = [];
|
||||||
|
let inTable = false;
|
||||||
|
|
||||||
|
const flushTable = (keyIdx: number) => {
|
||||||
|
if (tableRows.length === 0) return null;
|
||||||
|
const headers = tableRows[0];
|
||||||
|
const rows = tableRows.slice(2); // Skip separator row
|
||||||
|
|
||||||
|
const tableNode = (
|
||||||
|
<div key={`table-${keyIdx}`} className="my-6 overflow-x-auto rounded-2xl border border-slate-200 shadow-2xs">
|
||||||
|
<table className="w-full text-left text-xs font-sans">
|
||||||
|
<thead className="bg-slate-100 text-slate-900 uppercase font-bold tracking-wider border-b border-slate-200">
|
||||||
|
<tr>
|
||||||
|
{headers.map((h, hIdx) => (
|
||||||
|
<th key={hIdx} className="px-4 py-3">
|
||||||
|
{renderInline(h.trim())}
|
||||||
|
</th>
|
||||||
|
))}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody className="divide-y divide-slate-100 bg-white">
|
||||||
|
{rows.map((row, rIdx) => (
|
||||||
|
<tr key={rIdx} className="hover:bg-slate-50/80 transition-colors">
|
||||||
|
{row.map((cell, cIdx) => (
|
||||||
|
<td key={cIdx} className="px-4 py-3 text-slate-700 leading-relaxed">
|
||||||
|
{renderInline(cell.trim())}
|
||||||
|
</td>
|
||||||
|
))}
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
tableRows = [];
|
||||||
|
inTable = false;
|
||||||
|
return tableNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
for (let idx = 0; idx < lines.length; idx++) {
|
||||||
|
const line = lines[idx];
|
||||||
|
|
||||||
|
// Table parsing
|
||||||
|
if (line.trim().startsWith('|') && line.trim().endsWith('|')) {
|
||||||
|
inTable = true;
|
||||||
|
const cols = line.trim().slice(1, -1).split('|');
|
||||||
|
tableRows.push(cols);
|
||||||
|
continue;
|
||||||
|
} else if (inTable) {
|
||||||
|
const tableNode = flushTable(idx);
|
||||||
|
if (tableNode) nodes.push(tableNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Horizontal Divider
|
||||||
|
if (line.trim() === '---' || line.trim() === '***') {
|
||||||
|
nodes.push(
|
||||||
|
<hr key={idx} className="my-8 border-t border-slate-200" />
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Headings
|
||||||
|
if (line.startsWith('## ')) {
|
||||||
|
nodes.push(
|
||||||
|
<div key={idx} className="pt-8 pb-3 border-b border-slate-200 mb-4 first:pt-0">
|
||||||
|
<h2 className="text-2xl sm:text-3xl font-display font-bold text-slate-900 tracking-tight flex items-center gap-2.5">
|
||||||
|
<span className="w-2 h-6 rounded-full bg-accent inline-block" />
|
||||||
|
<span>{line.replace('## ', '')}</span>
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line.startsWith('### ')) {
|
||||||
|
nodes.push(
|
||||||
|
<h3 key={idx} className="text-lg sm:text-xl font-display font-bold text-slate-900 mt-6 mb-2 tracking-tight">
|
||||||
|
{renderInline(line.replace('### ', ''))}
|
||||||
|
</h3>
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line.startsWith('#### ')) {
|
||||||
|
nodes.push(
|
||||||
|
<h4 key={idx} className="text-sm sm:text-base font-display font-bold text-slate-800 mt-4 mb-1.5">
|
||||||
|
{renderInline(line.replace('#### ', ''))}
|
||||||
|
</h4>
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Blockquotes / Callout Boxes
|
||||||
|
if (line.startsWith('> ')) {
|
||||||
|
nodes.push(
|
||||||
|
<div key={idx} className="my-4 p-4 rounded-2xl bg-accent/5 border-l-4 border-accent text-slate-800 text-xs sm:text-sm font-sans flex items-start gap-3">
|
||||||
|
<ShieldCheck className="w-5 h-5 text-accent shrink-0 mt-0.5" />
|
||||||
|
<div className="leading-relaxed">
|
||||||
|
{renderInline(line.replace('> ', ''))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bullet List items
|
||||||
|
if (line.trim().startsWith('- ') || line.trim().startsWith('* ')) {
|
||||||
|
nodes.push(
|
||||||
|
<div key={idx} className="flex items-start gap-2.5 my-2 text-xs sm:text-sm text-slate-700 font-sans leading-relaxed pl-1">
|
||||||
|
<div className="w-1.5 h-1.5 rounded-full bg-accent mt-2 shrink-0" />
|
||||||
|
<div className="flex-1">{renderInline(line.trim().slice(2))}</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Numbered List items (e.g. "1. ", "12. ")
|
||||||
|
const numMatch = line.trim().match(/^(\d+)\.\s+(.*)/);
|
||||||
|
if (numMatch) {
|
||||||
|
const num = numMatch[1];
|
||||||
|
const rest = numMatch[2];
|
||||||
|
nodes.push(
|
||||||
|
<div key={idx} className="flex items-start gap-3 my-3 text-xs sm:text-sm text-slate-700 font-sans leading-relaxed">
|
||||||
|
<span className="w-6 h-6 rounded-full bg-slate-900 text-white font-mono text-xs font-bold flex items-center justify-center shrink-0 mt-0.5 shadow-2xs">
|
||||||
|
{num}
|
||||||
|
</span>
|
||||||
|
<div className="flex-1 pt-0.5">{renderInline(rest)}</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Empty Lines
|
||||||
|
if (line.trim().length === 0) {
|
||||||
|
nodes.push(<div key={idx} className="h-3" />);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normal Paragraph
|
||||||
|
nodes.push(
|
||||||
|
<p key={idx} className="text-xs sm:text-sm text-slate-600 font-sans leading-relaxed my-2.5">
|
||||||
|
{renderInline(line)}
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inTable) {
|
||||||
|
const tableNode = flushTable(lines.length);
|
||||||
|
if (tableNode) nodes.push(tableNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nodes;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="py-12 bg-white dark:bg-slate-900">
|
<section className="py-10 sm:py-16 bg-paper">
|
||||||
<div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
|
<div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||||
<div className="bg-slate-50 dark:bg-slate-950/60 rounded-3xl p-6 sm:p-10 border border-slate-200 dark:border-slate-800 shadow-sm">
|
<div className="studio-sheet rounded-3xl p-6 sm:p-12 bg-white border border-rule shadow-sheet">
|
||||||
{renderFormatted(markdown)}
|
{renderContent(markdown)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Reference in New Issue
Block a user