Construction mode hides pages from Markdown, MCP and search; MCP rejects non-object messages
createContentHelpers exposes isPathVisible (built from getConstructionMode) and passes it to markdownRoute and mcpPOST; createSearchRoute, createMcpRoute and createMarkdownRoute accept it. A null/number/string JSON-RPC message now gets -32600 instead of crashing the route. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
9a72ebfaff
commit
7c05a1dba9
@@ -6,6 +6,7 @@ import { cache } from 'react'
|
||||
import type { AnalyticsConfig } from '../analytics/types.js'
|
||||
import type { ConsentTexts } from '../consent/texts.js'
|
||||
import type { ConstructionMode } from '../construction/types.js'
|
||||
import type { PathVisibility } from '../construction/visibility.js'
|
||||
import type { ArchiveEntries, ContentOption, ResolvedRoute } from '../content/index.js'
|
||||
import type { I18nConfig } from '../i18n/index.js'
|
||||
import type { LinkValue, NavItem, ResolvedLink, ResolveLinkHrefOptions, SystemLink } from '../links/index.js'
|
||||
@@ -15,6 +16,7 @@ import type { PageMetadata, RobotsOptions, RobotsRules, SitemapEntry, SitemapSty
|
||||
|
||||
import { getAnalyticsConfig } from '../analytics/getAnalyticsConfig.js'
|
||||
import { getConsentTexts } from '../consent/getConsentTexts.js'
|
||||
import { isPathAllowed } from '../construction/logic.js'
|
||||
import { createMarkdownRoute } from '../content/createMarkdownRenderer.js'
|
||||
import { getArchiveEntries, resolveRoute as resolveRouteRaw } from '../content/index.js'
|
||||
import { MARKDOWN_PREFIX, markdownHref } from '../content/markdownNegotiation.js'
|
||||
@@ -685,6 +687,15 @@ export function createContentHelpers({
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* Is this page path public right now? False for pages construction mode
|
||||
* hides. The Markdown and MCP routes use it; pass it to createSearchRoute.
|
||||
*/
|
||||
const isPathVisible: PathVisibility = async (path, locale) => {
|
||||
const construction = await getConstructionMode(locale)
|
||||
return !construction.enabled || isPathAllowed(path, construction.allowedPaths)
|
||||
}
|
||||
|
||||
// ── Layout ────────────────────────────────────────────────────────────────
|
||||
/** Notifications → form texts in this locale (BuilderForm / RenderForm `texts`). */
|
||||
const getFormTexts = cache(async (locale: string): Promise<FormNotificationTexts> =>
|
||||
@@ -737,8 +748,8 @@ export function createContentHelpers({
|
||||
}
|
||||
const llms = lazy(() => createLlmsTxtRoute({ baseUrl: origin, config: needI18n('llmsRoute'), content, getCachedPayload, pagesSlug, settingsSlug, summaryField }))
|
||||
const llmsFull = lazy(() => createLlmsTxtRoute({ baseUrl: origin, config: needI18n('llmsFullRoute'), content, full: true, getCachedPayload, pagesSlug, settingsSlug, summaryField }))
|
||||
const md = lazy(() => createMarkdownRoute({ baseUrl: origin || undefined, collection: pagesSlug, config: i18n, content, getCachedPayload, settingsSlug, ...markdownOptions }))
|
||||
const mcp = lazy(() => createMcpRoute({ baseUrl: origin, collection: pagesSlug, config: needI18n('mcpRoute'), content, getCachedPayload, settingsSlug, summaryField, ...mcpOptions }))
|
||||
const md = lazy(() => createMarkdownRoute({ baseUrl: origin || undefined, collection: pagesSlug, config: i18n, content, getCachedPayload, isPathVisible, settingsSlug, ...markdownOptions }))
|
||||
const mcp = lazy(() => createMcpRoute({ baseUrl: origin, collection: pagesSlug, config: needI18n('mcpRoute'), content, getCachedPayload, isPathVisible, settingsSlug, summaryField, ...mcpOptions }))
|
||||
const health = lazy(() => createHealthRoute({ collection: pagesSlug, getCachedPayload }))
|
||||
const indexNowKey = lazy(() => createIndexNowKeyRoute({ getCachedPayload }))
|
||||
const manifestHandler = lazy(() => createManifestHandler({ config: needI18n('manifest'), getCachedPayload, settingsSlug }))
|
||||
@@ -765,6 +776,7 @@ export function createContentHelpers({
|
||||
getCachedPayload,
|
||||
getConfiguredLocales,
|
||||
getConstructionMode,
|
||||
isPathVisible,
|
||||
getEntries,
|
||||
getFormTexts,
|
||||
getHomeSlug,
|
||||
|
||||
Reference in New Issue
Block a user