38 lines
1.5 KiB
JavaScript
38 lines
1.5 KiB
JavaScript
/**
|
|
* Builds WebSite JSON-LD (schema.org). Two jobs:
|
|
* - Declares the site + name (helps Google associate brand queries with the site).
|
|
* - Optionally declares a SearchAction, which is what can produce the "sitelinks
|
|
* searchbox" (a search field under the brand result in Google).
|
|
*
|
|
* IMPORTANT — sitelinks (the sub-links under a result) CANNOT be forced. No
|
|
* schema guarantees them; Google generates them algorithmically from site
|
|
* structure, internal links, clear titles, and ranking. This schema is a SIGNAL
|
|
* that improves the odds and can enable the searchbox — not a switch. Manage
|
|
* expectations accordingly (see docs/seo.md).
|
|
*
|
|
* Emit once in the ROOT layout (site-wide), from panel data:
|
|
*
|
|
* import { buildWebSiteJsonLd } from '@intecion/ipal-kit'
|
|
* const jsonLd = buildWebSiteJsonLd({ name: settings.siteName, url: baseUrl })
|
|
* <script type="application/ld+json"
|
|
* dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }} />
|
|
*/ export function buildWebSiteJsonLd({ name, search, url }) {
|
|
return {
|
|
name,
|
|
'@context': 'https://schema.org',
|
|
'@type': 'WebSite',
|
|
url,
|
|
...search ? {
|
|
potentialAction: {
|
|
'@type': 'SearchAction',
|
|
'query-input': 'required name=search_term_string',
|
|
target: {
|
|
'@type': 'EntryPoint',
|
|
urlTemplate: search.target
|
|
}
|
|
}
|
|
} : {}
|
|
};
|
|
}
|
|
|
|
//# sourceMappingURL=buildWebSiteJsonLd.js.map
|