Import source: app/src/embed

Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality.
This commit is contained in:
arsam
2026-09-18 23:24:31 +03:30
parent 4b54e9a387
commit 7bbc93060a
+24
View File
@@ -0,0 +1,24 @@
// 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 />);
}