Docs (Public)

The following fields are available for use in the stackbit.yaml for Unibit themes only.

init_js

Used only when ssgName is unibit

This field is required to properly load and execute JavaScript files included in a theme when it is converted into Gatsby. This field should specify a path to a javascript file, relative to the static folder, that should be executed when the site is loaded by the browser and renders the initial page. For example, when a theme is converted to Gatsby, the file specified by this property is wrapped by Gatsby's onInitialClientRender API method. This method is executed when Gatsby finishes the initial rendering of the page. Code in this file could be used to manipulate or attach global event handlers to window, html or body elements. It must not store references or attach event handlers to elements located inside the body element, as these could be replaced by Gatsby when router navigation occurs. When a single instance element, such as a container for a dialog or a prompt, needs to be attached to the body element when the page is loaded, it can be be done in this file as well. Successive router navigation actions will not remove elements located directly in body as Gatsby changes the DOM only below its special container element having id="___gatsby".

page_load_js

Used only when ssgName is unibit

Similar to init_js, this field should specify a path to a javascript file, relative to the static folder, that should be executed to manipulate contents of the body element for every rendered page. For example, when a theme is converted to Gatsby, the file specified by this property is wrapped by Gatsby's onRouteUpdate API method. This method is executed when React renders a new page and router history is changed. Code in this file could be used to manipulate or attach event listeners to elements inside the body element.