setFrontmatter
Sets the front matter of a given content string.
When a FrontmatterFormattingPreserver is registered (see registerFrontmatterFormattingPreserver) the write goes through it first, so the parts of the block the change does not reach keep the bytes their author wrote — their comments, quoting, blank lines and indentation. Without one, and whenever the preserver reports it cannot be faithful, the whole block is parsed and written out again, which is what Obsidian’s own processFrontMatter() does.
Import:
import { setFrontmatter } from '@mnaoumov/obsidian-lib/frontmatter';Signature:
function setFrontmatter(content: string, newFrontmatter: object): stringParameters:
| Parameter | Type | Description |
|---|---|---|
content |
string | The content string to set the front matter in. |
newFrontmatter |
object | The new front matter to set. |
Returns: string — The new content string with the front matter set.
Links to this page: