Represents metadata describing a file. Returned by the
metadata() method on a File.
Type
Object
Properties
Holds the file's size in bytes (the length of its raw source), or null if unknown.
Available on: FileMetadata.
Show examplesHide examples
In this example, we read the size of the file open in the editor.
const { file_size } = await api.currentFile().metadata();
console.log(file_size);Holds an ISO 8601 timestamp of when the file was created, or null if unknown.
Available on: FileMetadata.
Show examplesHide examples
In this example, we read when the file was created.
const { created_at } = await api.currentFile().metadata();
console.log(`Created at ${new Date(created_at).toLocaleString()}`);Holds a timestamp of the file's most recent change, or null if unknown.
Available on: FileMetadata.
Show examplesHide examples
In this example, we read when the file was last changed.
const { last_modified } = await api.currentFile().metadata();
console.log(last_modified);Holds the file's resolved output data: its front matter merged with the data CloudCannon's build produces for it. The shape depends on the file, so this is loosely typed.
Available on: FileMetadata.
Show examplesHide examples
In this example, we read the file's resolved output data.
const { data } = await api.currentFile().metadata();
console.log(data);