diff --git a/config/_default/navigation.yml b/config/_default/navigation.yml deleted file mode 100644 index 05ea1e2..0000000 --- a/config/_default/navigation.yml +++ /dev/null @@ -1,21 +0,0 @@ -# 默认导航配置(请勿直接修改)。 -# 建议复制到 config/user/navigation.yml 并按需调整。 -# 规则: -# - 每个导航项的 id 必须唯一,并与 pages/.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 diff --git a/config/_default/site.yml b/config/_default/site.yml index 6d65700..d822cfd 100644 --- a/config/_default/site.yml +++ b/config/_default/site.yml @@ -50,3 +50,22 @@ social: - name: Steam url: https://steam.com 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 diff --git a/src/generator.js b/src/generator.js index 24c2362..930a147 100644 --- a/src/generator.js +++ b/src/generator.js @@ -233,13 +233,23 @@ function loadModularConfig(dirPath) { if (siteConfig.fonts) config.fonts = siteConfig.fonts; if (siteConfig.profile) config.profile = siteConfig.profile; if (siteConfig.social) config.social = siteConfig.social; + + // 优先使用site.yml中的navigation配置 + if (siteConfig.navigation) { + config.navigation = siteConfig.navigation; + console.log('使用 site.yml 中的导航配置'); + } } - // 加载导航配置 - const navConfigPath = path.join(dirPath, 'navigation.yml'); - const navConfig = safeLoadYamlConfig(navConfigPath); - if (navConfig) { - config.navigation = navConfig; + // 如果site.yml中没有navigation配置,则回退到独立的navigation.yml + if (!config.navigation || config.navigation.length === 0) { + const navConfigPath = path.join(dirPath, 'navigation.yml'); + const navConfig = safeLoadYamlConfig(navConfigPath); + if (navConfig) { + config.navigation = navConfig; + console.log('site.yml 中未找到导航配置,使用独立的 navigation.yml 文件'); + console.log('提示:建议将导航配置迁移到 site.yml 中,以便统一管理'); + } } // 加载页面配置