Hooks are a way to plug extra features (called actions) to VictorPy 0.1.32 at some pre-defined points. Common hooks use cases are: copying files, transpiling [some language] to JS/CSS/whatever, pinging some external service…
VictorPy 0.1.32 includes the fallowing hooks:
after_render
: when the pages rendering process is completed.affet_build
: when the site building process is completed.Configuring hook is generally two steps process:
For example, if you want to transpile your Less files to CSS each time your site has been rendered, you will have to say that you want to trigger the Less to CSS transpiling process after rendering and to tell VictorPy 0.1.32 where your Less source files are located andwhere you want to create the CSS files.
Linking actions to hooks is done using the hooks
config parameter:
hooks:
after_render: # the hook
- compile_less_files # the action to launch
# ...
Action related configuration should be done in a dedicated config parameters (every action defines its own configuration structure). For example:
less:
files:
- 'app/less/main.less': "static/css/main.min.css"
VictorPy 0.1.32 ships with a set of predefined actions:
Less is a CSS pre-processor. The compile_less_files
takes your Less files and transpile it into plain CSS files.
hooks:
after_render:
- copy_files(front)
less:
files:
- 'app/less/regular.less': "static/css/regular.css"
- 'app/less/home.less': "static/css/home.css"
- 'app/less/other.less': "static/css/other.css"
This action allow you to collect static files (inspired by the Django collectstatic command).
hooks:
after_render:
- copy_files(front)
- copy_files(static)
copy_files:
front:
'app/__javascript__/main.js': "static/js/main.js"
'app/__javascript__/other.js': "static/js/other.js"
static:
'/toto': 'tata'
Delete spaces in HTML files. Operates on files located in build_path.
hooks:
after_build:
- minify_html
This hook creates an index file for using with the Lunr search engine.
hooks:
after_render:
- create_lunr_index
To be documented.