Files
teknav-bak/app/src/embed.jsx
T
arsam 7bbc93060a Import source: app/src/embed
Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality.
2026-09-18 23:24:31 +03:30

25 lines
1.1 KiB
React

// Widget bootstrapper — reads URL path to render the correct widget.
// URL format: /embed/{type}/{slug}
// e.g. /embed/glossary/vector-database
import { createRoot } from 'react-dom/client';
import { GlossaryWidget } from './widgets/GlossaryWidget.jsx';
import { ArticleCardWidget } from './widgets/ArticleCardWidget.jsx';
import { CompanyWidget } from './widgets/CompanyWidget.jsx';
const [, , type, slug] = window.location.pathname.split('/');
function Widget() {
if (!type || !slug) {
return <div style={{ fontFamily: 'Vazirmatn,sans-serif', padding: 20, color: '#C62828', direction: 'rtl' }}>نوع ویجت نامعتبر است.</div>;
}
if (type === 'glossary') return <GlossaryWidget slug={slug} />;
if (type === 'article-card') return <ArticleCardWidget slug={slug} />;
if (type === 'company') return <CompanyWidget slug={slug} />;
return <div style={{ fontFamily: 'Vazirmatn,sans-serif', padding: 20, color: '#C62828', direction: 'rtl' }}>نوع ویجت «{type}» شناخته نشد.</div>;
}
const container = document.getElementById('widget-root');
if (container) {
createRoot(container).render(<Widget />);
}