35 lines
1.3 KiB
JavaScript
35 lines
1.3 KiB
JavaScript
/**
|
|
* Builds Organization JSON-LD (schema.org) — helps Google associate the site
|
|
* with a brand: name, logo, official links. Improves how the site appears in
|
|
* search (brand recognition, logo in knowledge panels) and is a signal used
|
|
* alongside favicon for identity.
|
|
*
|
|
* Returns a plain object; the project renders it as a <script type="application/
|
|
* ld+json"> in the root layout:
|
|
*
|
|
* import { buildOrganizationJsonLd } from '@intecion/ipal-kit'
|
|
* const jsonLd = buildOrganizationJsonLd({
|
|
* name: settings.siteName, url: baseUrl, logo: settings.logo,
|
|
* })
|
|
* <script type="application/ld+json"
|
|
* dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }} />
|
|
*
|
|
* Data comes from the panel (siteName, logo) — nothing hardcoded. Emit once in
|
|
* the root layout (Organization is site-wide, not per page).
|
|
*/ export function buildOrganizationJsonLd({ name, logo, sameAs, url }) {
|
|
const logoUrl = logo?.url;
|
|
return {
|
|
name,
|
|
'@context': 'https://schema.org',
|
|
'@type': 'Organization',
|
|
url,
|
|
...logoUrl ? {
|
|
logo: logoUrl.startsWith('http') ? logoUrl : `${url}${logoUrl}`
|
|
} : {},
|
|
...sameAs && sameAs.length > 0 ? {
|
|
sameAs
|
|
} : {}
|
|
};
|
|
}
|
|
|
|
//# sourceMappingURL=buildOrganizationJsonLd.js.map
|