公告栏模块突出一些重要的事情,比如新闻和项目的新版本。
| Module | github.com/hbstack/announcement-bar | 
|---|---|
| Repository | ⭐ Please consider giving a star if your like it. | 
| Stars | |
| Version | |
| Used by | |
| Requirements | |
| License | |
| Usage | See how to use modules. | 
| Parameter | Type | Default | Description | 
|---|---|---|---|
bg | string | primary | 背景颜色。 | 
color | string | #fff | 文本颜色。 | 
interval | number | 5000 | 公告的间隔,单位:毫秒。 | 
expand_stall_threshold | number | 1000 | 鼠标悬停于公告栏时展开所有公告所需要经过的毫秒数。 | 
hugo.toml
1[params]
2  [params.hb]
3    [params.hb.announcement_bar]
4      expand_stall_threshold = 1000
5      interval = 5000
hugo.yaml
1params:
2  hb:
3    announcement_bar:
4      expand_stall_threshold: 1000
5      interval: 5000
hugo.json
 1{
 2   "params": {
 3      "hb": {
 4         "announcement_bar": {
 5            "expand_stall_threshold": 1000,
 6            "interval": 5000
 7         }
 8      }
 9   }
10}
该模块被设计为兼容单语言和多语言站点,你需要于 data/announcements 目录下为每个语言站点创建公告数据文件。
1$ tree data/announcements
2├── en.toml
3├── zh-hans.toml
4└── zh-hant.toml
如 tree 的结果所示,我们为 en、zh-hans 和 zh-hant 站点定义了公告数据文件。
| Property | Type | Default | Required | Description | 
|---|---|---|---|---|
title | string | - | Y | 公告标题,支持 Markdown 语法。 | 
url | string | - | N | 公告 URL。 | 
weight | number | - | N | 值越小优先级越高。 | 
url,请确保 title 不包含无效内容,比如链接。data/announcements/en.toml
 1[external]
 2  title = 'The announcement linked to external site.'
 3  url = 'https://hugomods.com/'
 4  weight = 3
 5[internal]
 6  title = 'Internal announcement.'
 7  url = 'modules/enhancement/announcement-bar'
 8  weight = 2
 9[plain]
10  title = 'A **plain** text announcement.'
11  weight = 1
data/announcements/en.yaml
 1external:
 2  title: The announcement linked to external site.
 3  url: https://hugomods.com/
 4  weight: 3
 5internal:
 6  title: Internal announcement.
 7  url: modules/enhancement/announcement-bar
 8  weight: 2
 9plain:
10  title: A **plain** text announcement.
11  weight: 1
data/announcements/en.json
 1{
 2   "external": {
 3      "title": "The announcement linked to external site.",
 4      "url": "https://hugomods.com/",
 5      "weight": 3
 6   },
 7   "internal": {
 8      "title": "Internal announcement.",
 9      "url": "modules/enhancement/announcement-bar",
10      "weight": 2
11   },
12   "plain": {
13      "title": "A **plain** text announcement.",
14      "weight": 1
15   }
16}