Under construction mode (developer tool)
Site Settings -> Under construction: a switch, 'Pages still available' and notice texts. When on, only the homepage and the chosen pages open (every language); other addresses redirect to the homepage with the notice (createPageRoute redirect option), and <ConstructionNotice> cancels clicks on links to blocked pages and shows the notice. getConstructionMode(locale). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { CONSTRUCTION_NOTICE_PARAM, CONSTRUCTION_NOTICE_VALUE } from './types.js'
|
||||
|
||||
/** `/pl/` → `/pl`, `` → `/` — paths compare without a trailing slash. */
|
||||
export const normalizePath = (path: string): string => {
|
||||
const trimmed = path.replace(/\/+$/, '')
|
||||
return trimmed === '' ? '/' : trimmed
|
||||
}
|
||||
|
||||
/** Is this pathname one of the allowed ones? Exact match, trailing slash ignored. */
|
||||
export function isPathAllowed(pathname: string, allowedPaths: readonly string[]): boolean {
|
||||
const path = normalizePath(pathname)
|
||||
return allowedPaths.some((allowed) => normalizePath(allowed) === path)
|
||||
}
|
||||
|
||||
/** Where a blocked address goes: the homepage with the notice parameter. */
|
||||
export const constructionNoticeHref = (homePath: string): string =>
|
||||
`${homePath}?${CONSTRUCTION_NOTICE_PARAM}=${CONSTRUCTION_NOTICE_VALUE}`
|
||||
Reference in New Issue
Block a user