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]>
80 lines
3.1 KiB
TypeScript
80 lines
3.1 KiB
TypeScript
import type { Config } from 'payload'
|
|
|
|
import { describe, expect, test, vi } from 'vitest'
|
|
|
|
import type { I18nConfig } from '../src/modules/i18n/types.js'
|
|
|
|
import { ipalKit } from '../src/plugin.js'
|
|
|
|
const i18n: I18nConfig = {
|
|
defaultLocale: 'pl',
|
|
locales: [
|
|
{ code: 'pl', label: 'Polski' },
|
|
{ code: 'en', label: 'English' },
|
|
],
|
|
}
|
|
|
|
const base = (): Config =>
|
|
({
|
|
collections: [{ slug: 'users', auth: true, fields: [] }],
|
|
secret: 'test',
|
|
}) as unknown as Config
|
|
|
|
describe('ipalKit — config transform', () => {
|
|
test('adds globals, endpoint, localization and roles', async () => {
|
|
const config = await ipalKit({ access: { authCollection: 'users' }, i18n, twoFactor: false })(base())
|
|
|
|
expect(config.globals?.map((g) => g.slug)).toEqual(
|
|
expect.arrayContaining(['site-settings', 'site-integrations']),
|
|
)
|
|
expect(config.endpoints?.some((e) => e.path === '/ipal/test-email')).toBe(true)
|
|
expect(config.localization && config.localization.defaultLocale).toBe('pl')
|
|
|
|
const users = config.collections?.find((c) => c.slug === 'users')
|
|
expect(users?.fields.some((f) => 'name' in f && f.name === 'roles')).toBe(true)
|
|
})
|
|
|
|
test('enforces 2FA unless explicitly disabled', async () => {
|
|
await expect(ipalKit({ i18n } as never)(base())).rejects.toThrow(/twoFactor\.issuer is required/)
|
|
await expect(ipalKit({ i18n, twoFactor: { issuer: 'Acme' } } as never)(base())).rejects.toThrow(
|
|
/no 2FA plugin was injected/,
|
|
)
|
|
|
|
const totp = vi.fn(() => (c: Config) => c)
|
|
await ipalKit({ i18n, twoFactor: { issuer: 'Acme', plugin: totp as never } })(base())
|
|
expect(totp).toHaveBeenCalledWith(expect.objectContaining({ forceSetup: true, totp: { issuer: 'Acme' } }))
|
|
})
|
|
|
|
test('enabled: false leaves the config untouched', async () => {
|
|
const config = base()
|
|
expect(await ipalKit({ enabled: false, i18n, twoFactor: false })(config)).toBe(config)
|
|
})
|
|
|
|
test('invalid i18n fails fast', () => {
|
|
expect(() => ipalKit({ i18n: { defaultLocale: 'de', locales: i18n.locales }, twoFactor: false })).toThrow()
|
|
})
|
|
})
|
|
|
|
describe('ipalKit — auth collection', () => {
|
|
test('injects a users auth collection when the project has none, with roles', async () => {
|
|
const config = await ipalKit({ access: { authCollection: 'users' }, i18n, twoFactor: false })({
|
|
collections: [],
|
|
secret: 'x',
|
|
} as unknown as Config)
|
|
const users = config.collections?.find((c) => c.slug === 'users')
|
|
expect(users?.auth).toBe(true)
|
|
expect(users?.fields.some((f) => 'name' in f && f.name === 'roles')).toBe(true)
|
|
})
|
|
|
|
test("keeps the project's own users collection", async () => {
|
|
const own = { slug: 'users', auth: true, fields: [{ name: 'fullName', type: 'text' }] }
|
|
const config = await ipalKit({ access: { authCollection: 'users' }, i18n, twoFactor: false })({
|
|
collections: [own],
|
|
secret: 'x',
|
|
} as unknown as Config)
|
|
const users = config.collections?.filter((c) => c.slug === 'users')
|
|
expect(users).toHaveLength(1)
|
|
expect(users?.[0].fields.some((f) => 'name' in f && f.name === 'fullName')).toBe(true)
|
|
})
|
|
})
|