MCP site tools, Turnstile key alert, required 2FA injection, a11y, more tests

- MCP: new get_site_info and list_pages tools (public by design, published
  and indexable content only); search results collapse the homepage to root.
  New listContent() helper shared with searchContent.
- Dashboard alert when Turnstile is half-configured (it is silently off then).
- twoFactor.plugin is now required; the dynamic-import fallback (which never
  worked under Next and caused a Turbopack warning) is gone.
- a11y: cookie category checkboxes are labelled, buttons have type, test-email
  input is labelled; tab labels keep localized collection labels.
- IPAL_IP_HEADER: one-time production warning when unset, opt-in
  ipalEnvRules({ ipHeader: true }).
- Tests: SEO/robots/sitemap/hreflang, CSP, Markdown, consent, MCP, and a real
  Payload + SQLite integration test for forms and the roles guard (74 total).
- Drop unused mongodb-memory-server; dev .env.example for SQLite.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-16 01:15:19 +02:00
co-authored by Claude Opus 5.5
parent 86e69b0bcf
commit ab854ef37a
36 changed files with 708 additions and 328 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ export { resolveNotFoundPage } from './resolveNotFoundPage.js'
export { resolveRedirect } from './resolveRedirect.js'
export { resolveRoute } from './resolveRoute.js'
export type { ResolvedRoute } from './resolveRoute.js'
export { searchContent } from './searchContent.js'
export { listContent, searchContent } from './searchContent.js'
export type { SearchResult } from './searchContent.js'
export type { ContentCollectionOption, ContentOption } from './types.js'
export { archiveFieldName } from './types.js'
+52 -2
View File
@@ -89,6 +89,20 @@ export async function searchContent({
return []
}
return toResults(docs, { config, homeSlug, locale: loc, max, origin, summaryField })
}
type ToResultsArgs = {
config: I18nConfig
homeSlug?: Record<string, string> | string
locale: string
max: number
origin: string
summaryField?: string
}
/** Published, indexable docs → results. Shared by searchContent and listContent. */
function toResults(docs: PageRow[], { config, homeSlug, locale, max, origin, summaryField }: ToResultsArgs): SearchResult[] {
const results: SearchResult[] = []
for (const doc of docs) {
if (doc._status && doc._status !== 'published') {continue}
@@ -96,7 +110,7 @@ export async function searchContent({
const title = typeof doc.title === 'string' ? doc.title : undefined
const slug = typeof doc.slug === 'string' ? doc.slug : undefined
if (!title || !slug) {continue}
const path = buildLocalizedPath({ config, homeSlug, locale: loc, slugs: { [loc]: slug } })
const path = buildLocalizedPath({ config, homeSlug, locale, slugs: { [locale]: slug } })
// Prefer the richer AI summary when configured and present, else meta.description.
const summary =
summaryField && typeof doc[summaryField] === 'string'
@@ -113,6 +127,42 @@ export async function searchContent({
})
if (results.length >= max) {break}
}
return results
}
/**
* Every published, indexable page of a collection (title order), as the same
* structured results searchContent returns — the "table of contents" an AI
* agent browses before fetching pages. Behind the MCP server's list_pages tool.
*
* Degrades to [] (never throws) like searchContent.
*/
export async function listContent({
baseUrl,
collection = 'pages',
config,
homeSlug,
limit = 50,
locale,
payload,
summaryField,
}: Omit<SearchContentArgs, 'query'>): Promise<SearchResult[]> {
const loc = locale && isValidLocale(locale, config) ? locale : getDefaultLocale(config)
const max = Math.min(Math.max(Math.trunc(limit) || 50, 1), 200)
const origin = baseUrl?.replace(/\/$/, '') ?? ''
let docs: PageRow[] = []
try {
const res = await payload.find({
collection: collection as never,
depth: 0,
limit: max * 2, // over-fetch; drafts/noindex filtered in memory
locale: loc as never,
sort: 'title',
})
docs = (res?.docs ?? []) as PageRow[]
} catch {
return []
}
return toResults(docs, { config, homeSlug, locale: loc, max, origin, summaryField })
}