Skip to content

Commit f1bf742

Browse files
committed
feat: add support for hiding anchor icon with false value in configuration
1 parent 5c43bd0 commit f1bf742

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

README.en.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,8 @@ v1.0.0 added `anchor_icon` configuration for customizing anchor icons, defaults
11531153
anchor_icon: # if the icon is empty, the default # icon is used
11541154
```
11551155

1156+
v1.8.5 `anchor_icon` supports passing `false` to hide anchor icon.
1157+
11561158
##### Cursor Icon (v1.3.0+)
11571159

11581160
v1.3.0 added `reimu_cursor.cursor` configuration for customizing cursor icons. You can fill in a path relative to `css/style.css` to customize cursor icons.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,8 @@ v1.0.0 增加了 `anchor_icon` 配置用于自定义锚点图标,默认使用
11571157
anchor_icon: # 不填默认使用 # 图标
11581158
```
11591159

1160+
v1.8.5 `anchor_icon` 支持传递 `false` 以隐藏锚点图标。
1161+
11601162
##### 鼠标图标(v1.3.0+)
11611163

11621164
v1.3.0 增加了 `reimu_cursor.cursor` 配置用于自定义鼠标图标,你可以填写一个相对于 `css/style.css` 的路径来自定义鼠标图标。

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ i18n:
159159
# CSS
160160
########################################
161161

162-
anchor_icon: # default use '#' icon, you can use a hexadecimal representation of fontawesome or icon_font, like 'f0c1'
162+
anchor_icon: # default use '#' icon, you can use a hexadecimal representation of fontawesome or icon_font, like 'f0c1', or you can use false to hide anchor icon
163163

164164
reimu_cursor:
165165
enable: true

scripts/helper/config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ hexo.extend.helper.register("themeConfig", function () {
2727
addConfig("swPath", url_for.call(hexo, "/sw.js"));
2828
}
2929
addConfig("outdate", config.outdate?.enable ? config.outdate : null);
30-
addConfig("anchor_icon", config.anchor_icon);
30+
if (config.anchor_icon || config.anchor_icon === false) {
31+
_global.push(
32+
`window.REIMU_CONFIG.anchor_icon = ${
33+
typeof config.anchor_icon === "string" ? `'${config.anchor_icon}'` : JSON.stringify(config.anchor_icon)
34+
};`
35+
);
36+
}
3137
addConfig("code_block", config.code_block);
3238
addConfig("base", siteConfig.url);
3339
if (config.i18n?.enable) {

source/js/pjax_script.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ _$$(
3434
// iconfont
3535
element.innerHTML = window.REIMU_CONFIG.anchor_icon
3636
? `&#x${window.REIMU_CONFIG.anchor_icon};`
37-
: "";
37+
: window.REIMU_CONFIG.anchor_icon === false ? "" : "";
3838
} else {
3939
// fontawesome
4040
element.innerHTML = window.REIMU_CONFIG.anchor_icon
4141
? `&#x${window.REIMU_CONFIG.anchor_icon};`
42-
: "";
42+
: window.REIMU_CONFIG.anchor_icon === false ? "" : "";
4343
}
4444
});
4545

0 commit comments

Comments
 (0)