Virtual Files API

Limesdocs manipulates virtual files, meaning that these files do not necessarily exist on a filesystem. This is a great abstraction which allows Limedocs to source, transform, and output practically anything, everywhere. Once created, virtual files pass through the whole pipeline and can be modified without touching the filesystem.


The VFile class that Limedocs exposes extends the vfile class from unifiedjs. Make sure to check their implementation to check all properties and methods originally supported.


import { vfile } from "@limedocs/core"
// vfile is a function that you can use to create new Virtual files

const myFile = vfile({
  path: "/my/path/to/file.txt", 
  contents: "Hello world"


vfile({ path: string, contents: Buffer | string}): VFile

Helper method to create a new virtual file.

VFile properties

contentTypeFile content-type. Will be automatically computed based on path extension. If Limedocs cannot determine it, it will be set to application/octet-stream. Can also be passed directly in contructor options.
contextAn object describing the file context.
datastoreThe datastore instance attached to the file.
pathFile path
contentsFile contents.

See also original properties and methods of unifiedjs's vfile format.

Edit this page / submit change