Skip to main content

splitFrontMatter

@forge/monorepo


@forge/monorepo / backend/src / splitFrontMatter

Function: splitFrontMatter()

splitFrontMatter(lines): object

Defined in: backend/src/documents/parsers/text.ts:128

A leading --- block, split off before anything else reads the document — task #220.

Returns the remaining lines and the scalar keys, and names what it could not read rather than guessing. Front matter is metadata about a document, not part of it: left in the stream it becomes a paragraph, gets chunked and embedded, and can be returned as a retrieval hit — so a question about revenue policy can be answered with a block of YAML.

Scalar keys only. generated: { by: x, at: y } read as the string { by: x, at: y } would be provenance recorded as if it had been understood, which is worse than a warning saying it was skipped.

Parameters

lines

readonly string[]

Returns

object

body

readonly body: readonly string[]

fields

readonly fields: Record<string, string>

warnings

readonly warnings: readonly string[]