Core Module

The github.com/hbstack/hb is the core module of HB framework, which automatically loads and compiles the module’s SCSS and TypeScript, as well as rendering HTML.

Modulegithub.com/hbstack/hb
Repository⭐ Please consider giving a star if your like it.
Stars
Version
Used by
Requirements
License
UsageSee how to use modules.

Features

  • Implements HugoPress.
  • Baseof template.
  • Fix flickering issue of dark mode on redirect pages.

How it Works?

HB is built on top of HugoPress, a UI-less modular framework that defines several hooks for loading modules automatically.

Module

Module Structure

HB module MUST be placed at the assets/hb/modules folder, which has the following structure.

1tree assets/hb/modules/vendor-module
2├── js
3│   └── index.ts
4├── purgecss.config.toml
5└── scss
6    ├── index.scss
7    └── variables.tmpl.scss

HB will:

  • Loads SCSS variables from scss/variables.tmpl.scss, and then loads and compiles scss/index.scss into the CSS bundle.
  • Loads and compiles the js/index.ts into the JS bundle.
  • The purgecss.config.toml used to add styles to PurgeCSS whitelist, in order to avoid getting removing.

Module Naming Convention

We recommend naming your HB module in form: vendor-name, in order to avoid conflicting with HB built-in modules.

  • vendor: your name or organization name.
  • name: the module name.

See also creating a module.

Site Parameters

NameTypeRequiredDefaultDescription
css_bundle_namestring-hbThe bundle name of CSS.
debugboolean-falseDebug mode.
js_bundle_namestring-hbThe bundle name of JS.
logostring-images/logo.pngThe logo path relative to assets folder.

hugo.toml

1[params]
2  [params.hb]
3    css_bundle_name = 'hb'
4    debug = false
5    js_bundle_name = 'hb'
6    logo = 'images/logo.png'

hugo.yaml

1params:
2  hb:
3    css_bundle_name: hb
4    debug: false
5    js_bundle_name: hb
6    logo: images/logo.png

hugo.json

 1{
 2   "params": {
 3      "hb": {
 4         "css_bundle_name": "hb",
 5         "debug": false,
 6         "js_bundle_name": "hb",
 7         "logo": "images/logo.png"
 8      }
 9   }
10}

HugoPress Attributes

NameDescription
hb-mainFor .hb-main.

HugoPress Hooks

NameDescription
hb-body-beginFollows the body-begin hook.
hb-body-endBefore the body-end hook.