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:
1
_change = false;
2
_active: boolean;
3
_synthetic: boolean;
4
readonly _root: string;
5
readonly _id: string;
6
readonly _src?: string;
7
readonly _dir: string;
8
readonly _name: string;
9
readonly _ext: string;
10
_out: string;
11
readonly _basename: string;
12
readonly _path: string;
13
readonly _uuid;
14
readonly _spig: Spig;
Copied!

Attributes

Attributes are associated data of a FileRef. Attributes are (or should be:) only accessible using the methods:
1
attr(name); // reads attribute
2
setAttr(name, val); // sets attribute
3
setAttrsFrom(object); // copies attributes from the object (Objects.assign)
4
addAttrsFrom(object); // adds non-existing attributes from given object
5
hasAttr(name); // detects if attribute exist
Copied!

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
Last modified 1yr ago
Export as PDF
Copy link