-
Notifications
You must be signed in to change notification settings - Fork 0
SsgFile
javarome edited this page May 21, 2024
·
4 revisions
Ssg manipulates files through a SsgFile types, which contain:
- the
nameof the file (including relative path) - the detected (or specified)
encodingof the file contents (utf8,latin1, etc.) - the
contentsof the file, as a string - the
lastModifiedDate of the file - the detected (or specified)
language of the file contents and itsvariants(file_fr.txtwill imply french for instance).
You can:
- get one for an existing (likely input) file using
SsgFile.read(context, fileName, encoding?) - get or create in memory (if it doesn't exist) using
SsgFile.readOrNew(context, fileName, encoding?) - save its (likely output) contents it in the output directory, using
context.file.write()
HTML files automatic parsing will provide additional properties:
-
titlewill contain the value of the<title>tag, if any -
metawill contain values ofurl,copyrightandauthormeta tags (a repeatedauthormeta tag will result in an array of author strings) -
linkswill contain values ofstart,contents,prevandnextrelationships -
domwill contain a JSDOM instance, so you can querydom.window.documentto get the parsed document.