FileRef

File in Spignite is just a collection of meta-data

File reference is an object that contains file information. It is passed to every Spignite operation.

It contains the following properties:

_change = false;
_active: boolean;
_synthetic: boolean;
readonly _root: string;
readonly _id: string;
readonly _src?: string;
readonly _dir: string;
readonly _name: string;
readonly _ext: string;
_out: string;
readonly _basename: string;
readonly _path: string;
readonly _uuid;
readonly _spig: Spig;

Attributes

Attributes are associated data of a FileRef. Attributes are (or should be:) only accessible using the methods:

attr(name); // reads attribute
setAttr(name, val); // sets attribute
setAttrsFrom(object); // copies attributes from the object (Objects.assign)
addAttrsFrom(object); // adds non-existing attributes from given object
hasAttr(name); // detects if attribute exist

Content

Content can be reached as Buffer or a simple string, using methods: buffer() or string().

Context

While FileRef is available for all Spignite operations and file manipulation, it is NOT available inside any content! In another words, FileRef is not available for rendering/templating.

FileRef is available for Spignite ops; the context for the rendering/templating.

For that purpose, each FileRef has a context() method that returns actual context that IS available on page! It consist of:

  • all the attributes

  • site- global meta data

  • link - full link to the file

  • url - permalink

  • src - dir + name of the source file

  • content - string content of a file