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:
@@ -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 />);
|
||||
}
|
||||
Reference in New Issue
Block a user