plugin-static-html

The static HTML generator will essentially use the rendering engine and the http transport to save all the rendered HTML for all the given routes, to the file system, as static HTML pages.

Note that this plugin works by performing a GET request to the alias of all registered actions and saving the result HTML into the static folder, using the given alias as the file path. This entire documentation is made with this plugin, so you can check it out.

Installation and usage
# install the plugin
npm i --save thorin-plugin-static-html@1.x
'use strict';
   // app.js entry file
   const thorin = require('thorin');

   thorin.addPlugin(require('thorin-plugin-static-html'));   // <-- add this line
   thorin.run((err) => {});

# run once to allow the plugin to set itself up
   node app.js --setup=plugin.static-html
Default configuration
  • actionsnull specific actions to download only. If set, it should be an array of action names.
  • outputthorin.root + public/staticthe output directory for the static HTML pages. You can also make this public/ in order to ship your entire public/ folder as the static page.
  • transporthttpthe name of the HTTP transport to work with
  • wait1000the number of milliseconds before we start performing request and saving the HTML.
  • autoruntrueautomatically start compiling the HTML files. If set to false, you have to manually call the generate() function
  • sitemap.compilefunctionthe compile function that we use to generate the sitemap.xml file. You do not have to override this, as it defaults to the internal one.
  • sitemap.frequencyweeklyspecify how frequent the page changes are.
  • sitemap.domainnullif you want the sitemap file to work with your domain, enter it here.
Note: setting sitemap to false will avoid generating the sitemap.xml file
Plugin functionality
pluginObj.generate(fn)
Manually start the HTML and sitemap generator and call the function when done.
pluginObj.generatePaths(paths, fn)
Given an array of HTTP paths, it will perform the generate() on them. This is useful when your application consists of dynamic routes or aliases.
  • pathsarray(string) an array of HTTP paths to perform the GET on. The resulting HTML path will be the same as the URL.
Note: when we do this, we essentially simulate the custom actions, by adding them to the dispatcher.
It is advised that you terminate the process once the generator has completed.
A small example:
/my/action/right/here converts to thorin.root + /public/static/my/action/right/here.html
Do you have a question or is something missing?

You can always create a new issue on GitHub or contact one of the core founders by chat.