refactor: migrate TrumpSignal to TypeScript monorepo and Pages Router
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
// Emits a schema.org/BreadcrumbList as JSON-LD. Server-component friendly —
|
||||
// renders only a <script> tag, no visible DOM. Helps Google breadcrumb rich
|
||||
// results and gives AI answer engines the page's entity hierarchy.
|
||||
//
|
||||
// Usage (server component):
|
||||
// <Breadcrumbs items={[{ name: 'Methodology', path: '/en/methodology' }]} />
|
||||
// "Home" is prepended automatically; pass the page itself as the last item.
|
||||
|
||||
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || 'https://trumpsignal.com'
|
||||
|
||||
export interface Crumb {
|
||||
name: string
|
||||
path: string // e.g. "/en/methodology"
|
||||
}
|
||||
|
||||
export default function Breadcrumbs({ items }: { items: Crumb[] }) {
|
||||
const all: Crumb[] = [{ name: 'Trump Alpha', path: '/en' }, ...items]
|
||||
const jsonLd = {
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'BreadcrumbList',
|
||||
itemListElement: all.map((c, i) => ({
|
||||
'@type': 'ListItem',
|
||||
position: i + 1,
|
||||
name: c.name,
|
||||
item: `${siteUrl}${c.path}`,
|
||||
})),
|
||||
}
|
||||
return (
|
||||
<script
|
||||
type="application/ld+json"
|
||||
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
|
||||
/>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user