Skip to content

SsgFile

javarome edited this page Jun 9, 2024 · 4 revisions

Ssg manipulates files through a FileContents types, which contain:

  • the name of the file (including relative path)
  • the detected (or specified) encoding of the file contents (utf8, latin1, etc.)
  • the contents of the file, as a string
  • the lastModified Date of the file
  • the detected (or specified) language of the file contents and its variants (file_fr.txt will imply french for instance).

You can:

  • get one for an existing (likely input) file using FileContents.read(context, fileName, encoding?)
  • get or create in memory (if it doesn't exist) using FileContents.readOrNew(context, fileName, encoding?)
  • save its (likely output) contents it in the output directory, using context.file.write()

HtmlFileContents

HTML files automatic parsing will provide additional properties:

  • title will contain the value of the <title> tag, if any
  • meta will contain values of url, copyright and author meta tags (a repeated author meta tag will result in an array of author strings)
  • links will contain values of start, contents, prev and next relationships
  • dom will contain a JSDOM instance, so you can query dom.window.document to get the parsed document.
Clone this wiki locally