Box is a container used for processing files in a specified folder. Hexo uses two different boxes:
hexo.theme. The former is used to process the
source folder and the latter to process the
Box provides two methods for loading files:
process loads all files in the folder.
watch does the same, but also starts watching for file changes.
Box provides many ways for path matching. You can use a regular expression, a function or an Express-style pattern string. For example:
See util.Pattern for more info.
A processor is an essential element of Box and is used to process files. You can use path matching as described above to restrict what exactly the processor should process. Register a new processor with the
Box passes the content of matched files to processors. This information can then be read straight from the
file argument in the callback:
||Full path of the file|
||Relative path to the box of the file|
||File type. The value can be
||The information from path matching.|
Box also provides some methods so you don’t have to do file IO by yourself.
||Read a file|
||Read a file synchronously|
||Read the status of a file|
||Read the status of a file synchronously|
||Render a file|
||Render a file synchronously|