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
+8 -2
View File
@@ -31,6 +31,12 @@ export type RenderRichTextProps = {
* converter still renders the heading; the id is added to what it returns.
*/
headingIds?: { className?: string; levels?: readonly HeadingLevel[] } | boolean
/**
* Links whose URL isn't a safe target (`javascript:`, `data:`…) render as
* '#'. Default true; `false` renders stored URLs as they are (only for
* content you fully trust).
*/
safeLinks?: boolean
}
type HeadingNode = { children?: unknown[]; tag: HeadingLevel }
@@ -97,10 +103,10 @@ function withHeadingIds(
* <TableOfContents items={extractHeadings(page.content)} label={toc.label} /> // /client
* <RenderRichText data={page.content} headingIds={{ className: 'scroll-mt-24' }} />
*/
export function RenderRichText({ className, converters, data: raw, headingIds }: RenderRichTextProps) {
export function RenderRichText({ className, converters, data: raw, headingIds, safeLinks = true }: RenderRichTextProps) {
if (!raw) {return null}
// javascript:/data: link URLs from stored content never reach an href
const data = sanitizeRichTextLinks(raw)
const data = safeLinks ? sanitizeRichTextLinks(raw) : raw
if (headingIds) {
const opts = headingIds === true ? {} : headingIds
const ids = computeHeadingIds(data, opts.levels ? { levels: opts.levels } : {})