diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index dc1a8726..b27b9445 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -1,5 +1,26 @@ import { defineConfig } from 'vitepress' +const localSearch = { + provider: 'local' as const, + options: { + translations: { + button: { + buttonText: '搜索', + buttonAriaLabel: '搜索文档' + }, + modal: { + noResultsText: '无法找到相关结果', + resetButtonTitle: '清除查询条件', + footer: { + selectText: '选择', + navigateText: '切换', + closeText: '关闭' + } + } + } + } +} + function safeGenericEscapePlugin() { return { name: 'safe-generic-escape', @@ -62,6 +83,10 @@ export default defineConfig({ chunkSizeWarningLimit: 1000 } }, + themeConfig: { + // 在顶层保留搜索配置,避免构建期只读取站点级配置时把搜索入口裁掉。 + search: localSearch + }, /** 多语言 */ locales: { root: { @@ -71,41 +96,21 @@ export default defineConfig({ themeConfig: { logo: '/logo-icon.png', - - search: { - provider: 'local', - options: { - translations: { - button: { - buttonText: '搜索文档', - buttonAriaLabel: '搜索文档' - }, - modal: { - noResultsText: '无法找到相关结果', - resetButtonTitle: '清除查询条件', - footer: { - selectText: '选择', - navigateText: '切换', - closeText: '关闭' - } - } - } - } - }, + search: localSearch, nav: [ { text: '首页', link: '/zh-CN/' }, { text: '入门指南', link: '/zh-CN/getting-started' }, { text: 'Core', link: '/zh-CN/core/' }, - { text: 'ECS', link: '/zh-CN/ecs/' }, { text: 'Game', link: '/zh-CN/game/' }, { text: 'Godot', link: '/zh-CN/godot/' }, - { text: '源码生成器', link: '/zh-CN/source-generators' }, { text: '教程', link: '/zh-CN/tutorials/' }, - { text: '最佳实践', link: '/zh-CN/best-practices/' }, { text: '更多', items: [ + { text: 'ECS', link: '/zh-CN/ecs/' }, + { text: '源码生成器', link: '/zh-CN/source-generators' }, + { text: '最佳实践', link: '/zh-CN/best-practices/' }, { text: 'API 参考', link: '/zh-CN/api-reference' }, { text: '常见问题', link: '/zh-CN/faq' }, { text: '故障排查', link: '/zh-CN/troubleshooting' }, diff --git a/docs/.vitepress/theme/style.css b/docs/.vitepress/theme/style.css index 03029e0d..56ec7d14 100644 --- a/docs/.vitepress/theme/style.css +++ b/docs/.vitepress/theme/style.css @@ -132,3 +132,46 @@ --vp-custom-block-tip-code-bg: var(--vp-c-brand-soft); } +/** + * Component: Navigation + * -------------------------------------------------------------------------- */ + +@media (min-width: 768px) and (max-width: 1279px) { + /* Keep the search entry visible on medium desktop widths where nav links are the tightest. */ + .VPNavBarSearch { + flex: 0 0 auto; + padding-left: 16px; + } + + .VPNavBarSearch .VPNavBarSearchButton { + min-width: 0; + padding: 8px 10px; + } + + .VPNavBarSearch .keys { + display: none; + } + + .VPNavBarMenu { + min-width: 0; + } + + .VPNavBarMenu .VPNavBarMenuLink, + .VPNavBarMenu .VPFlyout .button { + padding-left: 10px; + padding-right: 10px; + font-size: 13px; + } +} + +@media (min-width: 1280px) { + /* Reserve stable room for the search button before appearance and social actions appear. */ + .VPNavBarSearch { + min-width: 176px; + } + + .VPNavBarSearch .VPNavBarSearchButton { + justify-content: space-between; + min-width: 176px; + } +}