feat: 将导航配置合并到站点配置中
- 将导航配置从独立的 navigation.yml 合并到 site.yml 中 - 更新 generator.js 以优先使用 site.yml 中的导航配置 - 添加回退机制,当 site.yml 中无导航配置时仍支持独立的 navigation.yml
This commit is contained in:
@@ -1,21 +0,0 @@
|
|||||||
# 默认导航配置(请勿直接修改)。
|
|
||||||
# 建议复制到 config/user/navigation.yml 并按需调整。
|
|
||||||
# 规则:
|
|
||||||
# - 每个导航项的 id 必须唯一,并与 pages/<id>.yml 对应
|
|
||||||
# - 全局仅允许一个 active: true 作为默认激活页面
|
|
||||||
- name: 首页 # 菜单名称
|
|
||||||
icon: fas fa-home # Font Awesome 图标类
|
|
||||||
id: home # 页面标识符(唯一,需与 pages/home.yml 对应)
|
|
||||||
active: true # 是否默认激活(全局仅一个 true)
|
|
||||||
- name: 项目
|
|
||||||
icon: fas fa-project-diagram
|
|
||||||
id: projects
|
|
||||||
- name: 文章
|
|
||||||
icon: fas fa-book
|
|
||||||
id: articles
|
|
||||||
- name: 朋友
|
|
||||||
icon: fas fa-users
|
|
||||||
id: friends
|
|
||||||
- name: 书签
|
|
||||||
icon: fas fa-bookmark
|
|
||||||
id: bookmarks
|
|
||||||
@@ -50,3 +50,22 @@ social:
|
|||||||
- name: Steam
|
- name: Steam
|
||||||
url: https://steam.com
|
url: https://steam.com
|
||||||
icon: fab fa-steam
|
icon: fab fa-steam
|
||||||
|
|
||||||
|
# 导航配置
|
||||||
|
navigation:
|
||||||
|
- name: 首页 # 菜单名称
|
||||||
|
icon: fas fa-home # Font Awesome 图标类
|
||||||
|
id: home # 页面标识符(唯一,需与 pages/home.yml 对应)
|
||||||
|
active: true # 是否默认激活(全局仅一个 true)
|
||||||
|
- name: 项目
|
||||||
|
icon: fas fa-project-diagram
|
||||||
|
id: projects
|
||||||
|
- name: 文章
|
||||||
|
icon: fas fa-book
|
||||||
|
id: articles
|
||||||
|
- name: 朋友
|
||||||
|
icon: fas fa-users
|
||||||
|
id: friends
|
||||||
|
- name: 书签
|
||||||
|
icon: fas fa-bookmark
|
||||||
|
id: bookmarks
|
||||||
|
|||||||
@@ -233,13 +233,23 @@ function loadModularConfig(dirPath) {
|
|||||||
if (siteConfig.fonts) config.fonts = siteConfig.fonts;
|
if (siteConfig.fonts) config.fonts = siteConfig.fonts;
|
||||||
if (siteConfig.profile) config.profile = siteConfig.profile;
|
if (siteConfig.profile) config.profile = siteConfig.profile;
|
||||||
if (siteConfig.social) config.social = siteConfig.social;
|
if (siteConfig.social) config.social = siteConfig.social;
|
||||||
|
|
||||||
|
// 优先使用site.yml中的navigation配置
|
||||||
|
if (siteConfig.navigation) {
|
||||||
|
config.navigation = siteConfig.navigation;
|
||||||
|
console.log('使用 site.yml 中的导航配置');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载导航配置
|
// 如果site.yml中没有navigation配置,则回退到独立的navigation.yml
|
||||||
|
if (!config.navigation || config.navigation.length === 0) {
|
||||||
const navConfigPath = path.join(dirPath, 'navigation.yml');
|
const navConfigPath = path.join(dirPath, 'navigation.yml');
|
||||||
const navConfig = safeLoadYamlConfig(navConfigPath);
|
const navConfig = safeLoadYamlConfig(navConfigPath);
|
||||||
if (navConfig) {
|
if (navConfig) {
|
||||||
config.navigation = navConfig;
|
config.navigation = navConfig;
|
||||||
|
console.log('site.yml 中未找到导航配置,使用独立的 navigation.yml 文件');
|
||||||
|
console.log('提示:建议将导航配置迁移到 site.yml 中,以便统一管理');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载页面配置
|
// 加载页面配置
|
||||||
|
|||||||
Reference in New Issue
Block a user