← @mortar-kit/core

normalizeDocfunction

import { normalizeDoc } from '@mortar-kit/core'

function normalizeDoc(collection: AnyCollection, bricks: readonly AnyBrick[], raw: unknown): Doc

Coerces unknown data (a stored file, data from props) into a document that renders and edits safely. A missing or invalid id falls back to the slug, so hand-written files need none (the next save stores it). With a body, entries are normalized; without one, stored entries are kept as plain JSON but never rendered, so turning body off loses nothing. A position is kept when it is a finite number. The input is never modified.

Parameters

collection: AnyCollection
bricks: readonly AnyBrick[]
raw: unknown

Returns

Doc