Methods
loadAddedScripts()
Get the external scripts added to , define the globals they would define, and fire their
load events in order.
- Source:
module:hexo/filter/locals(hexo)
Register the Hexo filter for merging theme and site config, and add all helper functions to a
dedicated property (
It also adds a new variable named
helper) in the locals.
This filter will try to merge
- the post/page config defined in the Markdown file's front-matter,
- post/page config defined in
themes/[theme_name]/_config.post.ymlorthemes/[theme_name]/_config.page.yml, - post/page layout config defined in
[site_root]/_config.post.ymlor[site_root]/_config.page.yml, - theme config defined in
themes/[theme_name]/_config.ymlornode_modules/hexo-theme-[theme_name]/_config.ymlif it is installed as an NPM package, - and the site config defined in
_config.yml,
It also adds a new variable named
helper, containing all Hexo helper functions, to the page
locals so that you can them through it instead.
It is useful for passing helper functions to the cacheable view components.
NOTE: This filter must be registered before any other Hexo extensions or views in order to take effect.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
hexo |
Hexo
|
The Hexo instance. |
module:hexo/generator/assets(hexo)
Register the Hexo generator for exporting text-based asset files like JavaScript and CSS.
The asset files are under the asset/ folder of this library. If a file of the same path already exists in the theme's source folder, the asset file in this library will not be exported.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
hexo |
Hexo
|
The Hexo instance. |
module:hexo/generator/categories(hexo)
Register the Hexo generator for generating the
/categories/ page.
A __categories: true property will be attached to the page local
variables.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
hexo |
Hexo
|
The Hexo instance. |
module:hexo/generator/category(hexo)
Register the Hexo generator for generating
/category/ pages.
An array of parent categories will be attached to the page local variables.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
hexo |
Hexo
|
The Hexo instance. |
module:hexo/generator/insight(hexo)
Insight search content.json generator.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
hexo |
Hexo
|
The Hexo instance. |
module:hexo/generator/manifest(hexo)
Web app manifest.json generator.
Manifest configurations should be placed in the `head.manifest` property of the theme configurations.
Manifest configurations should be placed in the `head.manifest` property of the theme configurations.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
hexo |
Hexo
|
The Hexo instance. |
Example
head:
manifest:
name:
short_name:
start_url:
theme_color:
background_color:
display: standalone
icons:
- src: /path/to/image.png
sizes: 128x128
type: image/png
module:hexo/generator/tags(hexo)
Register the Hexo generator for generating the
/tags/ page.
A __tags: true property will be attached to the page local
variables.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
hexo |
Hexo
|
The Hexo instance. |
module:hexo/helper/cdn(hexo)
Register the Hexo helper functions for resolving the URL of static files of JavaScript libraries,
web fonts, and FontAwesome icon fonts.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
hexo |
Hexo
|
The Hexo instance. |
Example
// Use the function below to resolve the CDN URL JavaScript library static files in your view files
cdn('jquery', '3.3.1', 'dist/jquery.min.js');
// -> https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js
// Set providers.cdn_overrides, e.g., { jquery: 'unpkg' }, to use a different CDN provider or URL
// template for some packages
cdn('jquery', '3.3.1', 'dist/jquery.min.js');
// -> https://unpkg.com/jquery@3.3.1/dist/jquery.min.js
// Use the function below to resolve the CDN URL web font files
fontcdn('Ubuntu:400,600|Source+Code+Pro', 'css');
// -> https://fonts.googleapis.com/css?family=Ubuntu:400,600|Source+Code+Pro
// Use the function below to insert FontAwesome icon font CSS URL.
iconcdn();
// -> https://use.fontawesome.com/releases/v6.0.0/css/all.css
module:hexo/helper/page(hexo)
Register the Hexo helper functions for a Hexo page/post.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
hexo |
Hexo
|
The Hexo instance. |
Example
// Use the function below to test if the given page is the /categories page
// Need to be combined with lib/hexo/generator/categories
is_categories(page);
// Use the function below to test if the given page is the /tags page
// Need to be combined with lib/hexo/generator/tags
is_tags(page);
module:hexo/tag/message(hexo)
Register custom Hexo tag {% message %}.
Tag Parameters:
This tag is rendered as a Bulma message box.
Tag Parameters:
| Name | Type | Description |
|---|---|---|
color |
string |
[Optional] Color of the message. Available values are: dark, primary, link, info, success, warning, danger. |
icon |
string |
[Optional] Icon shown in the message header. Use FontAwesome icon class name for this field. |
title |
string |
[Optional] Message title in the message header. Markdown is supported. |
size |
string |
[Optional] Size of the message box. Available values are: small, medium, large. Default size is normal. |
Parameters:
| Name | Type | Description |
|---|---|---|
hexo |
Hexo
|
The Hexo instance. |
Example
{% message color:warning 'icon:fas fa-info-circle' 'title:*ATTENTION*' size:small %}
**This is a warning message.**
{% endmessage %}
module:hexo/tag/tabs(hexo)
Register custom Hexo tag {% tabs %}.
Tag Parameters:
Tab Parameters:
This tag is rendered as a Bulma tabs component.
Each individual tab must be wrapped with <!-- tab [...tab_param] --><!-- endtab -->
Tag Parameters:
| Name | Type | Description |
|---|---|---|
align |
string |
[Optional] Alignment of the tabs. Available values are: left, centered, right, fullwidth. Default alignment is left. |
size |
string |
[Optional] Size of the tabs. Available values are: small, medium, large. Default size is normal. |
style |
string |
[Optional] Style of the tabs. Available values are: boxed, toggle, toggle-rounded. Default style is none. |
Tab Parameters:
| Name | Type | Description |
|---|---|---|
id |
string |
[Optional] The ID of the current tab. This value must be unique on each page. |
active |
boolean |
[Optional] Whether to show current tab by default. Only one of the tabs can be set to active. |
title |
string |
[Optional] Title of the current tab. |
icon |
string |
[Optional] Icon of the current tab. Use FontAwesome icon class name for this field. |
Parameters:
| Name | Type | Description |
|---|---|---|
hexo |
Hexo
|
The Hexo instance. |
Example
{% tabs align:fullwidth size:small style:toggle-rounded %}
<!-- tab active id:tab_hello title:Hello -->
This is hello.
<!-- endtab -->
<!-- tab id:tab_info 'icon:fas fa-info' 'title:Info Tab' -->This is info.<!-- endtab -->
{% endtabs %}
module:util/classname(classname) → {string}
A utility function for creating classnames from a string, array, or classname-to-boolean map.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
classname |
string
|
Array
|
Object
|
A class name string, an array of class names, or a plain object whose keys are possible class names and values are booleans that indicate whether the class name is active. |
Throws:
-
The input classname is neither a string, an array, or a plain object.
- Type
-
Error
Returns:
- Type:
-
string
The class name string.
renderAndRun()
Render a comment component, check that it does not block rendering, and run its inline script.
Scripts set with innerHTML are not run by the browser, so the inline script is run manually.
- Source:
renderClientScript()
Render a comment component that adds its client script to a thread element, run its inline script
with the given appearance, and get the client script from the thread element.
- Source:
renderWaline()
Render Waline, check that its script is a classic script that PJAX can run, and run the script with
the dynamic import replaced, since Jest cannot import the URL.
- Source:
search()
Run the Insight search script on the given content, and search for the given query.
- Source: