Skip to content

Latest commit

 

History

History
184 lines (138 loc) · 6.62 KB

reference.md

File metadata and controls

184 lines (138 loc) · 6.62 KB

id: reference title: "Reference" content-type: page

This section provides some reference information related to the default metadata of contents and assets, as well as the full documentation of the hastysite min Module.

Default Content and Asset Metadata

The following table lists all the default metadata properties available for contents and assets, and also after which build phase they become available.

%note% Note

You can define your own custom metadata for contents in a header section delimited by five dashes, at the start of each content file.

%responsive%

Property Content Asset
id
path
ext
type
title ^1
content-type ^1
date ^(1,2)
timestamp ^(1,2)
contents ^3 ^3

%unstyled%

  • 1 This property is defined for all page and post contents created using the default page and post commands.
  • 2 This property is defined for all post contents created using the default post command.
  • 3 This property must be added to contents and assets before they can be written to the output folder. This can be done implicitly using symbols provided with the hastysite min module.

hastysite min Module

This min module can be imported in the rules.min file or in any script file and can be used to perform common operations such as ready and writing files, and interact with HastySite data at build time.

{{null => ∅}} {{d => dict}} {{q => quot}} {{m => meta}} {{qm => (meta*)}} {{q1 => quot1}} {{q2 => quot2}} {{s => string}} {{s1 => string1}} {{s2 => string2}}

{#op =>

$1

%operator% $2 $3

$4 #}

{#op||assets||{{null}}||{{qm}}|| Returns a quotation of metadata dictionaries {{qm}} containing the metadata of each asset file. #}

{#op||clean-output||{{null}}||{{null}}|| Deletes all the contents of the output directory. #}

{#op||clean-temp||{{null}}||{{null}}|| Deletes all the contents of the temp directory. #}

{#op||contents||{{null}}||{{qm}}|| Returns a quotation of metadata dictionaries {{qm}} containing the metadata of each content file. #}

{#op||input-fread||{{m}}||{{s}}|| Reads the contents of the file identified by the metadata dictionary {{m}} (such as those returned by the contents and assets parameters).

Note that:

  • The source directory is determined by the value of the type metadata property.
  • The path within the source directory is determined by the value of the path metadata property. #}

{#op||markdown||{{s1}} {{d}}||{{s2}}|| Converts the HastyScribe Markdown string {{s1}} into the HTML fragment {{s2}}, using the properties of {{d}} as custom fields (accessible therefore via HastyScribe's {{$<field-name>}} syntax). #}

{#op||mustache||{{s1}} {{d}}||{{s2}}|| Renders mustache template {{s1}} into {{s2}}, using dictionary {{d}} as context.

%note% Note

{{s1}} is the path to the mustache template file, relative to the templates directory and without .mustache. #}

{#op||output||{{null}}||{{s}}|| Returns the full path to the output directory. #}

{#op||output-cp||{{m}}||{{null}}|| Copies a file from the source directory (contents or assets depending on its type) to the output directory.

Note that:

  • The source directory is determined by the value of the type metadata property.
  • The path within the source directory is determined by the value of the path metadata property.
  • The destination path within the output directory is determined by the value of concatenation of the id and ext metadata properties.
  • The contents of the file are retrieved from the contents metadata property (in case of contents) or the contents of the original file (in case of assets).

#}

{#op||output-fwrite||{{m}}||{{null}}|| Writes the contents of the file identified by the metadata dictionary {{m}} (such as those returned by the contents and assets parameters).

Note that:

  • The destination path within the output directory is determined by the value of concatenation of the id and ext metadata properties.
  • The contents of the file are retrieved from the contents metadata property (in case of contents) or the contents of the original file (in case of assets).

#}

{#op||postprocess||{{null}}||{{null}}|| Starts the postprocessing phase of the build. #}

{#op||preprocess||{{null}}||{{null}}|| Starts the preprocessing phase of the build. #}

{#op||preprocess-css||{{s1}}||{{s2}}|| Pre-process CSS contents within {{s1}}, i.e.:

  1. Pseudo-SCSS partial imports. Partial CSS files must start with an underscore and be placed in the css-partials directory (set in your settings.json, or assets/styles if not specified).
  2. CSS variable declarations

Returns the resulting CSS code {{s2}}.

For example, the following CSS code in two different files:

_vars.css: : ``` :root { --standard-gray: #cccccc; }


style.css:
: ```
@import 'vars';
.note {
  background-color: var(--standard-gray);  
}

Will be converted into the following:

:root {
  --standard-gray: #cccccc;
}

.note {
  background-color: #cccccc;  
}

%warning% Limitation

Only basic support for CSS variables is provided, e.g. no fallback values are supported. #}

{#op||process-rules||{{null}}||{{null}}|| Starts the processing phase of the build, and interprets the rules.min file. #}

{#op||settings||{{null}}||{{d}}|| Returns a dictionary {{d}} containing all the settings defined in the settings.json file. #}