fix: 补齐书签 subgroups 渲染并对齐 README
- 修复 subgroups 生成但不展示的问题(模板渲染 + 前端结构导出) - 更新 README:配置示例/完全替换策略/多层级说明与 helper 文档,减少重复说明
This commit is contained in:
@@ -179,6 +179,14 @@ MeNav 的助手函数分为四类:
|
||||
{{json this}}
|
||||
```
|
||||
|
||||
#### extractDomain
|
||||
|
||||
从 URL 中提取“干净的域名”(不包含协议、路径与查询串),常用于站点描述兜底显示:
|
||||
|
||||
```handlebars
|
||||
{{extractDomain url}}
|
||||
```
|
||||
|
||||
### 条件判断函数
|
||||
|
||||
#### ifEquals / ifNotEquals
|
||||
@@ -311,6 +319,22 @@ MeNav 的助手函数分为四类:
|
||||
{{/each}}
|
||||
```
|
||||
|
||||
#### encodeURIComponent
|
||||
|
||||
对字符串做 URL 组件编码,常用于拼接第三方请求参数(例如 favicon 的 `url=` 参数):
|
||||
|
||||
```handlebars
|
||||
{{encodeURIComponent url}}
|
||||
```
|
||||
|
||||
#### add
|
||||
|
||||
数字加法,用于根据层级动态计算标题级别等场景:
|
||||
|
||||
```handlebars
|
||||
<h{{add level 1}}>...</h{{add level 1}}>
|
||||
```
|
||||
|
||||
### 核心函数
|
||||
|
||||
#### escapeHtml
|
||||
|
||||
@@ -398,13 +398,13 @@ function updateCategoryToggleIcon(state) {
|
||||
}
|
||||
}
|
||||
|
||||
window.MeNav.toggleCategory = function(categoryName, subcategoryName = null, groupName = null) {
|
||||
const selector = groupName
|
||||
? `[data-name="${categoryName}"] [data-name="${subcategoryName}"] [data-name="${groupName}"]`
|
||||
: subcategoryName
|
||||
? `[data-name="${categoryName}"] [data-name="${subcategoryName}"]`
|
||||
: `[data-name="${categoryName}"]`;
|
||||
|
||||
window.MeNav.toggleCategory = function(categoryName, subcategoryName = null, groupName = null, subgroupName = null) {
|
||||
let selector = `[data-name="${categoryName}"]`;
|
||||
|
||||
if (subcategoryName) selector += ` [data-name="${subcategoryName}"]`;
|
||||
if (groupName) selector += ` [data-name="${groupName}"]`;
|
||||
if (subgroupName) selector += ` [data-name="${subgroupName}"]`;
|
||||
|
||||
const element = document.querySelector(selector);
|
||||
if (element) {
|
||||
toggleNestedElement(element);
|
||||
@@ -500,6 +500,11 @@ function extractNestedData(element) {
|
||||
if (groups.length > 0) {
|
||||
data.groups = Array.from(groups).map(group => extractNestedData(group));
|
||||
}
|
||||
|
||||
const subgroups = element.querySelectorAll(':scope > .group-content > .subgroups-container > .group');
|
||||
if (subgroups.length > 0) {
|
||||
data.subgroups = Array.from(subgroups).map(subgroup => extractNestedData(subgroup));
|
||||
}
|
||||
|
||||
const sites = element.querySelectorAll(':scope > .category-content > .sites-grid > .site-card, :scope > .group-content > .sites-grid > .site-card');
|
||||
if (sites.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user