GEO / SEO
- collectSiteIndex: one list of public docs per locale (pages + archive
entries) on sitemap rules; llms.txt/llms-full and MCP list_pages now include
blog/content entries and every language. Fixes hard-coded "## Strony" heading
and homepage not collapsing to the locale root in llms.txt.
- Markdown frontmatter: canonical url + updated date.
- Metadata: X/Twitter card, OG image width/height/alt, og:type article with
published/modified times for entries.
- Fix: Site Settings "defaultShareImage" was never used — now the OG fallback.
- getPageJsonLd (createContentHelpers): WebPage/CollectionPage/BlogPosting,
BreadcrumbList from the real route, FAQPage via a project mapper.
- IndexNow (opt-in ipalKit({ indexNow: true })): submit published URLs in all
languages, key generated in Site Integrations or INDEXNOW_KEY, key route.
- sameAs profiles in Site Settings + sameAsUrls(); sitemap <image:image>.
From project reports
- Fix: package exports were missing ./env and ./fluid.css although the docs
import them (TS2307); regression test checks every documented subpath.
- Fix: plugins run before Payload adds its default users collection, so roles
and 2FA had nothing to attach to — ipalKit injects an auth collection when
the project has none (project's own one wins). Audit no longer errors on it.
- createMarkdownRoute, createSubmitAction (/server, headers injected).
- formatOpeningHours (PL/EN/DE text → schema.org), used by
buildLocalBusinessJsonLd, which also takes a schema.org `type`.
- buildNavigationJsonLd straight from the header global.
- buildCsp googleMaps: full Maps JS API domain set; values de-duplicated.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
97 lines
3.1 KiB
TypeScript
97 lines
3.1 KiB
TypeScript
import { formatOpeningHours } from './formatOpeningHours.js'
|
|
|
|
type MediaLike = { url?: null | string } | null | undefined
|
|
|
|
type Address = {
|
|
city?: string
|
|
country?: string // ISO code, e.g. 'PL'
|
|
postalCode?: string
|
|
region?: string
|
|
street?: string
|
|
}
|
|
|
|
type LocalBusinessJsonLdArgs = {
|
|
address?: Address
|
|
/** Geo coordinates for maps/local search. */
|
|
geo?: { latitude: number; longitude: number }
|
|
image?: MediaLike
|
|
logo?: MediaLike
|
|
name: string
|
|
/**
|
|
* Opening hours — schema.org strings (['Mo-Fr 08:00-18:00']) or the editor's
|
|
* own text in Polish/English/German ('Pn-Pt: 8-18, Sob: 9-14'); normalized by
|
|
* formatOpeningHours. Unreadable text is omitted, never emitted invalid.
|
|
*/
|
|
openingHours?: readonly string[] | string
|
|
priceRange?: string // e.g. '$$'
|
|
sameAs?: string[]
|
|
/** Business phone, e.g. '+48 123 456 789'. */
|
|
telephone?: string
|
|
/** schema.org type for this business, e.g. 'LegalService', 'Dentist', 'HVACBusiness'. Default 'LocalBusiness'. */
|
|
type?: string
|
|
url: string
|
|
}
|
|
|
|
/**
|
|
* Builds LocalBusiness JSON-LD (schema.org) — the key structured data for LOCAL
|
|
* SEO. Helps Google show the business in local results / map pack with address,
|
|
* hours, phone. Strong signal for "usługa + miasto" queries.
|
|
*
|
|
* All data from the panel (company global) — nothing hardcoded. Emit once in the
|
|
* root layout (business is site-wide):
|
|
*
|
|
* import { buildLocalBusinessJsonLd } from '@intecion/ipal-kit'
|
|
* const jsonLd = buildLocalBusinessJsonLd({
|
|
* name: company.name, url: baseUrl, telephone: company.phone,
|
|
* address: company.address, openingHours: company.hours,
|
|
* })
|
|
*
|
|
* For a more specific type (e.g. 'Dentist', 'Plumber'), override @type in the
|
|
* returned object — schema.org has many LocalBusiness subtypes.
|
|
*/
|
|
export function buildLocalBusinessJsonLd({
|
|
name,
|
|
type = 'LocalBusiness',
|
|
address,
|
|
geo,
|
|
image,
|
|
logo,
|
|
openingHours,
|
|
priceRange,
|
|
sameAs,
|
|
telephone,
|
|
url,
|
|
}: LocalBusinessJsonLdArgs) {
|
|
const hours = formatOpeningHours(openingHours)
|
|
const logoUrl = logo?.url
|
|
const imageUrl = image?.url ?? logoUrl
|
|
|
|
return {
|
|
name,
|
|
'@context': 'https://schema.org',
|
|
'@type': type,
|
|
url,
|
|
...(telephone ? { telephone } : {}),
|
|
...(imageUrl ? { image: imageUrl.startsWith('http') ? imageUrl : `${url}${imageUrl}` } : {}),
|
|
...(logoUrl ? { logo: logoUrl.startsWith('http') ? logoUrl : `${url}${logoUrl}` } : {}),
|
|
...(address
|
|
? {
|
|
address: {
|
|
'@type': 'PostalAddress',
|
|
...(address.street ? { streetAddress: address.street } : {}),
|
|
...(address.city ? { addressLocality: address.city } : {}),
|
|
...(address.postalCode ? { postalCode: address.postalCode } : {}),
|
|
...(address.region ? { addressRegion: address.region } : {}),
|
|
...(address.country ? { addressCountry: address.country } : {}),
|
|
},
|
|
}
|
|
: {}),
|
|
...(geo
|
|
? { geo: { '@type': 'GeoCoordinates', latitude: geo.latitude, longitude: geo.longitude } }
|
|
: {}),
|
|
...(hours.length > 0 ? { openingHours: hours } : {}),
|
|
...(priceRange ? { priceRange } : {}),
|
|
...(sameAs && sameAs.length > 0 ? { sameAs } : {}),
|
|
}
|
|
}
|