Opt-outs for the secure defaults; isPathVisibleIn in construction/logic

- setUnknownIpFactor (0 = old free pass), UNKNOWN_IP_FACTOR exported
- createContentHelpers({ settingsDepth }) and markdown/mcp isPathVisible overrides
- <RenderRichText safeLinks={false}>
- resolveRedirect({ draft: true }) for preview
- isPathVisibleIn(mode, path), pathOf, PathVisibility exported; page route uses it

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-22 17:35:08 +02:00
co-authored by Claude Opus 5.5
parent 4585e0fc69
commit 0fd57c1d6a
13 changed files with 144 additions and 24 deletions
+12 -8
View File
@@ -16,7 +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 { isPathVisibleIn } 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'
@@ -55,7 +55,7 @@ type CreateContentHelpersArgs = {
*/
i18n?: I18nConfig
/** Markdown route (`markdownRoute`): per-block overrides, frontmatter, layout field. */
markdown?: { frontmatter?: boolean; layoutField?: string; overrides?: Record<string, (block: Record<string, unknown>) => string> }
markdown?: { frontmatter?: boolean; isPathVisible?: PathVisibility; layoutField?: string; overrides?: Record<string, (block: Record<string, unknown>) => string> }
/**
* Advertise each page's Markdown version from generatePageMetadata:
* `<link rel="alternate" type="text/markdown" href="/md/pl/o-nas">` (GEO —
@@ -65,7 +65,7 @@ type CreateContentHelpersArgs = {
*/
markdownAlternate?: boolean | string
/** MCP route (`mcpRoute`): server name/version, rate limit, batch size. */
mcp?: Pick<CreateMcpRouteArgs, 'clientIp' | 'maxBatch' | 'rateLimit' | 'serverName' | 'serverVersion'>
mcp?: Pick<CreateMcpRouteArgs, 'clientIp' | 'isPathVisible' | 'maxBatch' | 'rateLimit' | 'serverName' | 'serverVersion'>
/** Defaults for getPageJsonLd — each call can override them. */
pageJsonLd?: PageJsonLdOptions
/** Pages collection slug. Defaults to 'pages'. */
@@ -78,6 +78,12 @@ type CreateContentHelpersArgs = {
* `{ adminRoute: false }` when the admin path is hidden (ipalKit adminRoute).
*/
robots?: RobotsOptions
/**
* Depth of the Site Settings read behind getSettings / getSiteShell. Default
* 1 (relations as documents, their relations as ids). Raise it only if your
* layout reads deeper — every request pays for it.
*/
settingsDepth?: number
/** SiteSettings global slug. Defaults to 'site-settings'. */
settingsSlug?: string
/**
@@ -171,6 +177,7 @@ export function createContentHelpers({
pagesSlug = 'pages',
redirectCollections,
robots: robotsOptions,
settingsDepth = 1,
settingsSlug = 'site-settings',
siteJsonLd,
sitemapImages,
@@ -198,7 +205,7 @@ export function createContentHelpers({
*/
const getSettings = cache(async (locale: string) => {
const payload = await getCachedPayload()
return payload.findGlobal({ slug: settingsSlug as never, depth: 1, locale: locale as never })
return payload.findGlobal({ slug: settingsSlug as never, depth: settingsDepth, locale: locale as never })
})
/** What does this URL point at? Routing only — no listing data. */
@@ -691,10 +698,7 @@ 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)
}
const isPathVisible: PathVisibility = async (path, locale) => isPathVisibleIn(await getConstructionMode(locale), path)
// ── Layout ────────────────────────────────────────────────────────────────
/** Notifications → form texts in this locale (BuilderForm / RenderForm `texts`). */
+2 -2
View File
@@ -5,7 +5,7 @@ import type { ResolvedRoute } from '../content/index.js'
import type { ContentHelpers, PageJsonLdOptions } from './createContentHelpers.js'
import { RenderBlocks } from '../blocks/RenderBlocks.js'
import { constructionNoticeHref, isPathAllowed } from '../construction/logic.js'
import { constructionNoticeHref, isPathVisibleIn } from '../construction/logic.js'
import { LocaleView } from '../pages/LocaleView.js'
import { NotFoundLoader } from '../pages/NotFoundLoader.js'
import { JsonLdGraph } from '../seo/JsonLdGraph.js'
@@ -116,7 +116,7 @@ export function createPageRoute(helpers: Helpers, options: PageRouteOptions) {
const construction = await helpers.getConstructionMode(locale)
const multilingual = (helpers.i18n?.locales.length ?? 0) > 1
const path = `/${[...(multilingual ? [locale] : []), ...segments].join('/')}`
if (construction.enabled && !isPathAllowed(path, construction.allowedPaths)) {return redirect(constructionNoticeHref(construction.homePath))}
if (!isPathVisibleIn(construction, path)) {return redirect(constructionNoticeHref(construction.homePath))}
}
const route = await helpers.resolveRoute(locale, segments, 1)
if (!route) {