SEO: use construction/visibility pathOf (identical to security-perf branch) for the sitemap filter

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-22 17:20:37 +02:00
co-authored by Claude Opus 5.5
parent dc761164d9
commit 104cdbfd4c
2 changed files with 15 additions and 10 deletions
+10
View File
@@ -0,0 +1,10 @@
/**
* Is this public page path served right now? createContentHelpers builds it from
* Site Settings → Under construction (`isPathVisible`), so the Markdown, MCP and
* search routes hide exactly what the page route hides. Paths are page paths as
* a visitor sees them ('/pl/o-nas', or '/o-nas' on a single-language site).
*/
export type PathVisibility = (path: string, locale: string) => boolean | Promise<boolean>
/** Pathname of a result URL (absolute or relative), for a PathVisibility check. */
export const pathOf = (url: string): string => new URL(url, 'http://localhost').pathname
+5 -10
View File
@@ -16,6 +16,7 @@ import type { PageMetadata, RobotsOptions, RobotsRules, SitemapEntry, SitemapRou
import { getAnalyticsConfig } from '../analytics/getAnalyticsConfig.js'
import { getConsentTexts } from '../consent/getConsentTexts.js'
import { normalizePath } from '../construction/logic.js'
import { pathOf } from '../construction/visibility.js'
import { createMarkdownRoute } from '../content/createMarkdownRenderer.js'
import { getArchiveEntries, resolveRoute as resolveRouteRaw } from '../content/index.js'
import { MARKDOWN_PREFIX, markdownHref } from '../content/markdownNegotiation.js'
@@ -35,15 +36,6 @@ import { robotsOptionsFrom } from '../seo/searchSettings.js'
import { type ThemeConfig, themeConfigFrom } from '../theme/theme.js'
import { getTurnstileConfig } from '../turnstile/config.js'
/** Path of an absolute or relative URL: 'https://acme.pl/pl/o-nas' → '/pl/o-nas'. */
const pathOf = (url: string): string => {
try {
return new URL(url, 'http://local').pathname
} catch {
return url
}
}
type CreateContentHelpersArgs = {
/**
* Absolute site origin for sitemap/robots URLs. Falls back to
@@ -753,7 +745,10 @@ export function createContentHelpers({
/**
* While Site Settings → Under construction is on: the paths still open (every
* language), which the sitemap and llms.txt list instead of everything.
* null when the site is open or the setting can't be read.
* null when the site is open or the setting can't be read. Same rule as
* `isPathVisible`, but resolved ONCE per list: the sitemap may hold tens of
* thousands of URLs, and in a route handler React `cache` doesn't dedupe a
* per-URL settings read.
*/
const constructionPaths = async (): Promise<null | string[]> => {
if (!i18n || !underConstructionSeo) {return null}