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]>
73 lines
2.7 KiB
TypeScript
73 lines
2.7 KiB
TypeScript
import type { Field, GlobalConfig } from 'payload'
|
|
|
|
import { isAdmin } from '../../modules/access/index.js'
|
|
import { indexNowFields } from '../../modules/seo/indexNow.js'
|
|
import { analyticsFields } from './fields/analytics.js'
|
|
import { smtpFields } from './fields/smtp.js'
|
|
import { turnstileFields } from './fields/turnstile.js'
|
|
|
|
type BuildSiteIntegrationsArgs = {
|
|
/** Extra fields injected by the client project */
|
|
additionalFields?: Field[]
|
|
}
|
|
|
|
/**
|
|
* Builds the SiteIntegrations global.
|
|
*
|
|
* Holds third-party service credentials. Access is enforced at the global
|
|
* level — the whole global requires an authenticated user — so secrets stay
|
|
* out of anonymous API responses while remaining editable in the admin panel
|
|
* and readable via the server-side Local API. (Field-level read:false was
|
|
* avoided because it also hides fields from the admin UI, making them
|
|
* impossible to enter.)
|
|
*
|
|
* Unnamed tabs keep data flat (siteIntegrations.ga4MeasurementId).
|
|
*/
|
|
export function buildSiteIntegrations({
|
|
additionalFields,
|
|
}: BuildSiteIntegrationsArgs = {}): GlobalConfig {
|
|
return {
|
|
slug: 'site-integrations',
|
|
access: {
|
|
// Admin-only — secrets live here. Anonymous and non-admin users get
|
|
// nothing through the API; admins read/edit in the panel and via Local API.
|
|
read: ({ req: { user } }) => isAdmin(user),
|
|
update: ({ req: { user } }) => isAdmin(user),
|
|
},
|
|
admin: {
|
|
group: 'Settings',
|
|
},
|
|
fields: [
|
|
{
|
|
type: 'tabs',
|
|
tabs: [
|
|
{ fields: analyticsFields, label: 'Analytics' },
|
|
{ fields: turnstileFields, label: 'Turnstile' },
|
|
{ fields: smtpFields, label: 'SMTP' },
|
|
{ fields: indexNowFields, label: 'IndexNow' },
|
|
...(additionalFields?.length
|
|
? [{ fields: additionalFields, label: 'Custom' }]
|
|
: []),
|
|
],
|
|
},
|
|
],
|
|
hooks: {
|
|
beforeChange: [
|
|
// Keys edited in the panel → clear that integration's old status, so a stale
|
|
// "not working" banner doesn't linger until the next form submission.
|
|
({ context, data, originalDoc }) => {
|
|
if (context?.ipalIntegrationStatus || !data) {return data}
|
|
const changed = (k: string) => k in data && data[k] !== originalDoc?.[k]
|
|
const cleared = { checkedAt: null, code: null, message: null, since: null, state: null }
|
|
if (changed('turnstileSecretKey') || changed('turnstileSiteKey')) {data.turnstileStatus = cleared}
|
|
if (Object.keys(data).some((k) => (k === 'emailTransport' || k.startsWith('smtp')) && changed(k))) {
|
|
data.emailStatus = cleared
|
|
}
|
|
return data
|
|
},
|
|
],
|
|
},
|
|
label: 'Site Integrations',
|
|
}
|
|
}
|