github.com/hbstack/hb 是 HB 框架的核心模塊,其自動加載和編譯模塊的 SCSS 和 TypeScript,以及渲染 HTML。
| Module | github.com/hbstack/hb |
|---|---|
| Repository | ⭐ Please consider giving a star if your like it. |
| Stars | |
| Version | |
| Used by | |
| Requirements | |
| License | |
| Usage | See how to use modules. |
HB 是建立在 HugoPress 之上的,這是一個與用戶界面無關的模塊化框架,其定義了幾個鉤子用於自動加載模塊。
HB 模塊必須放在 assets/hb/modules 文件夾中,其結構如下。
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 將會:
scss/variables.tmpl.scss 中加載 SCSS 變量,然後加載並編譯 scss/index.scss 到 CSS 包中。js/index.ts 到 JS 包中。purgecss.config.toml 用於將樣式添加到 PurgeCSS 白名單中,以避免被刪除。我們建議將你的 HB 模塊命名爲:vendor-name,以避免與 HB 內置模塊發生衝突。
vendor:你或組織的名稱。name:模塊的名稱。custom 是爲用戶保留的。另請參閱創建模塊。
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
css_bundle_name | string | - | hb | CSS 的名稱。 |
debug | boolean | - | false | 調試模式。 |
js_bundle_name | string | - | hb | JS 的名稱。 |
logo | string | - | images/logo.png | Logo 路徑,相對於 assets 目錄。 |
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}
| Name | Description |
|---|---|
hb-main | .hb-main HTML 塊。 |
| Name | Description |
|---|---|
hb-body-begin | 於 body-begin 鉤子之後。 |
hb-body-end | 於 body-end 鉤子之前。 |