diff --git a/README.md b/README.md index d9fccab..f9de938 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,10 @@ - `sync-articles` 对齐 best-effort:同步失败不再以非 0 退出码阻断构建/部署 - 版本号来源统一:`window.MeNav.version` 不再写死,自动读取构建注入版本(用于扩展/调试识别) +**3. 模板图标 helper(Breaking)** + +- 模板 helper `faviconUrl` 更名为 `faviconV2Url`,避免与站点字段 `sites[].faviconUrl` 同名冲突;如有自定义模板调用 `{{faviconUrl url}}`,需同步改为 `{{faviconV2Url url}}` + ### 2026/01/03 关联 Issue:[#31](https://github.com/rbetree/menav/issues/31) diff --git a/config/_default/pages/common.yml b/config/_default/pages/common.yml index 78cb623..bbb96d0 100644 --- a/config/_default/pages/common.yml +++ b/config/_default/pages/common.yml @@ -16,6 +16,11 @@ categories: url: https://linux.do/ # http/https URL(favicon 模式将尝试加载站点图标) icon: fab fa-linux # 手动图标:manual 模式使用;favicon 模式下作为回退 description: 新的理想型社区 # 站点描述 + - name: Menav + url: https://rbetree.github.io/menav + icon: fas fa-star + description: 个人导航站 + faviconUrl: assets/menav.svg - name: Google url: https://www.google.com icon: fab fa-google diff --git a/src/helpers/utils.js b/src/helpers/utils.js index d8a0e00..299a486 100644 --- a/src/helpers/utils.js +++ b/src/helpers/utils.js @@ -199,9 +199,9 @@ function add(a, b) { * @param {string} url 站点 URL * @param {Object} options Handlebars options 对象 * @returns {string} favicon URL - * @example {{faviconUrl url}} + * @example {{faviconV2Url url}} */ -function faviconUrl(url, options) { +function faviconV2Url(url, options) { if (!url) return ''; const region = options.data.root.icons?.region || 'com'; @@ -304,7 +304,7 @@ module.exports = { keys, encodeURIComponent: encodeURIComponentHelper, add, - faviconUrl, + faviconV2Url, faviconFallbackUrl, safeUrl }; diff --git a/templates/README.md b/templates/README.md index 2a17619..a6b72e4 100644 --- a/templates/README.md +++ b/templates/README.md @@ -305,6 +305,8 @@ categories: - `forceIconMode: favicon | manual`:强制该站点使用指定模式(不设置则跟随全局 `icons.mode`) - 优先级:`faviconUrl` > `forceIconMode` > 全局 `icons.mode` +> 注意:用于根据站点 URL 生成 faviconV2 地址的模板 helper 已更名为 `faviconV2Url`,从而避免与站点字段 `faviconUrl` 同名冲突;自定义模板如需生成 faviconV2 地址,请使用 `{{faviconV2Url url}}`。如需强制读取站点字段 `faviconUrl`,也可使用 `{{lookup . "faviconUrl"}}`(推荐在复杂上下文中显式读取字段)。 + 示例(与内置组件实现保持一致): ```handlebars diff --git a/templates/components/site-card.hbs b/templates/components/site-card.hbs index a7969f2..0a6989b 100644 --- a/templates/components/site-card.hbs +++ b/templates/components/site-card.hbs @@ -1,7 +1,7 @@ {{#if url}}