-
Notifications
You must be signed in to change notification settings - Fork 0
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)
lang
uage of the file contents and itsvariants
(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()
HTML files automatic parsing will provide additional properties:
-
title
will contain the value of the<title>
tag, if any -
meta
will contain values ofurl
,copyright
andauthor
meta tags (a repeatedauthor
meta tag will result in an array of author strings) -
links
will contain values ofstart
,contents
,prev
andnext
relationships -
dom
will contain a JSDOM instance, so you can querydom.window.document
to get the parsed document.