frontmatter
Routines for serializing data structures into Markdown frontmatter blocks.
formatFrontMatterList()β
function formatFrontMatterList(prop, indentation?, prefix?): string[];
Defined in: frontmatter.ts:84
Formats an array into a front matter YAML-like structure as string array.
Parametersβ
propβ
unknown
The array to format.
indentation?β
number = 0
The current indentation level. Defaults to 0.
prefix?β
string = "- "
The prefix for each list item. Defaults to "- ".
Returnsβ
string[]
An array of strings representing the formatted front matter list.
Exampleβ
const list = ["item1", "item2"];
formatFrontMatterList(list);
// [
// "- item1",
// "- item2"
// ]
formatFrontMatterObject()β
function formatFrontMatterObject(props, indentation?, prefix?): string[];
Defined in: frontmatter.ts:44
Formats an object into a front matter YAML-like structure as string array.
Parametersβ
propsβ
unknown
The object to format.
indentation?β
number = 0
The current indentation level. Defaults to 0.
prefix?β
string
An optional prefix for each line.
Returnsβ
string[]
An array of strings representing the formatted front matter.
Exampleβ
const obj = { title: "My Title", tags: ["tag1", "tag2"] };
formatFrontMatterObject(obj);
// [
// " title: My Title",
// " tags:",
// " - tag1",
// " - tag2"
// ]
formatFrontMatterProp()β
function formatFrontMatterProp(prop, indentation?, prefix?): string[];
Defined in: frontmatter.ts:127
Formats a single property into a front matter YAML-like structure as string array.
Parametersβ
propβ
unknown
The property to format, represented as an object with a single key-value pair.
indentation?β
number = 0
The current indentation level. Defaults to 0.
prefix?β
string
An optional prefix for the property.
Returnsβ
string[]
An array of strings representing the formatted front matter property.
Exampleβ
const prop = { title: "My Title" };
formatFrontMatterProp(prop);
// [
// "title: My Title"
// ]