Accessed through a File's content property. Provides body-content access for
a file: everything after the front matter. Additionally, you can read or
replace a file's body as a string.
Type
Object
Properties
Returns the file's body content (everything after the front matter) as a
string. Resolves to undefined if the file does not exist.
Returns: A promise for the body content string.
Available on: FileContent.
Show examplesHide examples
In this example, we read the body content of the file open in the editor and log it.
const content = await api.currentFile().content.get();
console.log(content);Replaces the file's body content with the given string. This marks the file as having unsaved changes; a Team Member must save the Site to persist it. Has no effect if the file does not exist.
Returns: A promise that resolves once the change is applied to the editor.
Parameters:
contentstringRequired — The new body content, as a string.
Available on: FileContent.
Show examplesHide examples
In this example, we append a paragraph to the file's current body content.
const file = api.currentFile();
const content = await file.content.get();
await file.content.set(`${content}\n\nAppended paragraph.`);