diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index be7ce2c369..db66190d19 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -250,11 +250,11 @@ jobs: - name: Create release body run: | if [[ "${{ inputs.npm_tag }}" == "latest" ]]; then - INSTALL_BASH="curl -fsSL https://viteplus.dev/install.sh | bash" - INSTALL_PS1="irm https://viteplus.dev/install.ps1 | iex" + INSTALL_BASH="curl -fsSL https://vite.plus | bash" + INSTALL_PS1="irm https://vite.plus/ps1 | iex" else - INSTALL_BASH="curl -fsSL https://viteplus.dev/install.sh | VITE_PLUS_VERSION=${{ env.VERSION }} bash" - INSTALL_PS1="\\\$env:VITE_PLUS_VERSION=\\\"${{ env.VERSION }}\\\"; irm https://viteplus.dev/install.ps1 | iex" + INSTALL_BASH="curl -fsSL https://vite.plus | VITE_PLUS_VERSION=${{ env.VERSION }} bash" + INSTALL_PS1="\\\$env:VITE_PLUS_VERSION=\\\"${{ env.VERSION }}\\\"; irm https://vite.plus/ps1 | iex" fi cat > ./RELEASE_BODY.md <, pub sections: Vec, + pub documentation_url: Option<&'static str>, } #[derive(Clone, Debug)] @@ -29,6 +30,7 @@ struct OwnedHelpDoc { usage: String, summary: Vec, sections: Vec, + documentation_url: Option, } #[derive(Clone, Debug)] @@ -55,6 +57,33 @@ fn section_lines(title: &'static str, lines: Vec<&'static str>) -> HelpSection { HelpSection::Lines { title, lines } } +fn documentation_url_for_command_path(command_path: &[&str]) -> Option<&'static str> { + match command_path { + [] => Some("https://viteplus.dev/guide/"), + ["create"] => Some("https://viteplus.dev/guide/create"), + ["migrate"] => Some("https://viteplus.dev/guide/migrate"), + ["config"] | ["staged"] => Some("https://viteplus.dev/guide/commit-hooks"), + [ + "install" | "add" | "remove" | "update" | "dedupe" | "outdated" | "list" | "ls" | "why" + | "info" | "view" | "show" | "link" | "unlink" | "pm", + .., + ] => Some("https://viteplus.dev/guide/install"), + ["dev"] => Some("https://viteplus.dev/guide/dev"), + ["check"] => Some("https://viteplus.dev/guide/check"), + ["lint"] => Some("https://viteplus.dev/guide/lint"), + ["fmt"] => Some("https://viteplus.dev/guide/fmt"), + ["test"] => Some("https://viteplus.dev/guide/test"), + ["run"] => Some("https://viteplus.dev/guide/run"), + ["exec" | "dlx"] => Some("https://viteplus.dev/guide/vpx"), + ["cache"] => Some("https://viteplus.dev/guide/cache"), + ["build" | "preview"] => Some("https://viteplus.dev/guide/build"), + ["pack"] => Some("https://viteplus.dev/guide/pack"), + ["env", ..] => Some("https://viteplus.dev/guide/env"), + ["upgrade"] => Some("https://viteplus.dev/guide/upgrade"), + _ => None, + } +} + pub fn render_heading(title: &str) -> String { let heading = format!("{title}:"); if !should_style_help() { @@ -73,21 +102,12 @@ fn render_usage_value(usage: &str) -> String { } fn should_accent_heading(title: &str) -> bool { - matches!( - title, - "Start" - | "Develop" - | "Execute" - | "Build" - | "Manage Dependencies" - | "Maintain" - | "Setup" - | "Manage" - | "Inspect" - | "Examples" - | "Options" - | "Related Commands" - ) + title != "Usage" +} + +fn write_documentation_footer(output: &mut String, documentation_url: &str) { + let _ = writeln!(output); + let _ = writeln!(output, "{} {documentation_url}", render_heading("Documentation")); } pub fn should_style_help() -> bool { @@ -189,6 +209,10 @@ pub fn render_help_doc(doc: &HelpDoc) -> String { } } + if let Some(documentation_url) = doc.documentation_url { + write_documentation_footer(&mut output, documentation_url); + } + output } @@ -222,6 +246,10 @@ fn render_owned_help_doc(doc: &OwnedHelpDoc) -> String { } } + if let Some(documentation_url) = &doc.documentation_url { + write_documentation_footer(&mut output, documentation_url); + } + output } @@ -386,7 +414,7 @@ fn parse_clap_help_to_doc(raw_help: &str) -> Option { } } - Some(OwnedHelpDoc { usage, summary, sections }) + Some(OwnedHelpDoc { usage, summary, sections, documentation_url: None }) } pub fn top_level_help_doc() -> HelpDoc { @@ -459,6 +487,7 @@ pub fn top_level_help_doc() -> HelpDoc { ], ), ], + documentation_url: documentation_url_for_command_path(&[]), } } @@ -546,6 +575,7 @@ fn env_help_doc() -> HelpDoc { ], ), ], + documentation_url: documentation_url_for_command_path(&["env"]), } } @@ -577,6 +607,7 @@ fn delegated_help_doc(command: &str) -> Option { vec![" vp dev", " vp dev --open", " vp dev --host localhost --port 5173"], ), ], + documentation_url: documentation_url_for_command_path(&["dev"]), }), "build" => Some(HelpDoc { usage: "vp build [ROOT] [OPTIONS]", @@ -604,6 +635,7 @@ fn delegated_help_doc(command: &str) -> Option { vec![" vp build", " vp build --watch", " vp build --sourcemap"], ), ], + documentation_url: documentation_url_for_command_path(&["build"]), }), "preview" => Some(HelpDoc { usage: "vp preview [ROOT] [OPTIONS]", @@ -628,6 +660,7 @@ fn delegated_help_doc(command: &str) -> Option { ), section_lines("Examples", vec![" vp preview", " vp preview --port 4173"]), ], + documentation_url: documentation_url_for_command_path(&["preview"]), }), "test" => Some(HelpDoc { usage: "vp test [COMMAND] [FILTERS] [OPTIONS]", @@ -666,6 +699,7 @@ fn delegated_help_doc(command: &str) -> Option { ], ), ], + documentation_url: documentation_url_for_command_path(&["test"]), }), "lint" => Some(HelpDoc { usage: "vp lint [PATH]... [OPTIONS]", @@ -692,6 +726,7 @@ fn delegated_help_doc(command: &str) -> Option { ], ), ], + documentation_url: documentation_url_for_command_path(&["lint"]), }), "fmt" => Some(HelpDoc { usage: "vp fmt [PATH]... [OPTIONS]", @@ -714,6 +749,7 @@ fn delegated_help_doc(command: &str) -> Option { vec![" vp fmt", " vp fmt src --check", " vp fmt . --write"], ), ], + documentation_url: documentation_url_for_command_path(&["fmt"]), }), "check" => Some(HelpDoc { usage: "vp check [OPTIONS] [PATHS]...", @@ -737,6 +773,7 @@ fn delegated_help_doc(command: &str) -> Option { ], ), ], + documentation_url: documentation_url_for_command_path(&["check"]), }), "pack" => Some(HelpDoc { usage: "vp pack [...FILES] [OPTIONS]", @@ -759,6 +796,7 @@ fn delegated_help_doc(command: &str) -> Option { vec![" vp pack", " vp pack src/index.ts --dts", " vp pack --watch"], ), ], + documentation_url: documentation_url_for_command_path(&["pack"]), }), "run" => Some(HelpDoc { usage: "vp run [OPTIONS] [TASK_SPECIFIER] [ADDITIONAL_ARGS]...", @@ -809,6 +847,7 @@ fn delegated_help_doc(command: &str) -> Option { ], ), ], + documentation_url: documentation_url_for_command_path(&["run"]), }), "exec" => Some(HelpDoc { usage: "vp exec [OPTIONS] [COMMAND]...", @@ -862,6 +901,7 @@ fn delegated_help_doc(command: &str) -> Option { ], ), ], + documentation_url: documentation_url_for_command_path(&["exec"]), }), "cache" => Some(HelpDoc { usage: "vp cache ", @@ -870,6 +910,7 @@ fn delegated_help_doc(command: &str) -> Option { section_rows("Commands", vec![row("clean", "Clean up all the cache")]), section_rows("Options", vec![row("-h, --help", "Print help")]), ], + documentation_url: documentation_url_for_command_path(&["cache"]), }), _ => None, } @@ -1010,6 +1051,11 @@ pub fn print_unified_clap_help_for_path(command_path: &[&str]) -> bool { let Some(doc) = parse_clap_help_to_doc(&raw_help) else { return false; }; + let doc = OwnedHelpDoc { + documentation_url: documentation_url_for_command_path(command_path) + .map(ToString::to_string), + ..doc + }; println!("{}", vite_shared::header::vite_plus_header()); println!(); @@ -1020,8 +1066,8 @@ pub fn print_unified_clap_help_for_path(command_path: &[&str]) -> bool { #[cfg(test)] mod tests { use super::{ - has_help_flag_before_terminator, parse_clap_help_to_doc, parse_rows, split_comment_suffix, - strip_ansi, + HelpDoc, documentation_url_for_command_path, has_help_flag_before_terminator, + parse_clap_help_to_doc, parse_rows, render_help_doc, split_comment_suffix, strip_ansi, }; #[test] @@ -1110,4 +1156,32 @@ Options: fn split_comment_suffix_returns_none_without_comment() { assert!(split_comment_suffix(" vp env list").is_none()); } + + #[test] + fn docs_url_is_mapped_for_grouped_commands() { + assert_eq!( + documentation_url_for_command_path(&["add"]), + Some("https://viteplus.dev/guide/install") + ); + assert_eq!( + documentation_url_for_command_path(&["env", "list"]), + Some("https://viteplus.dev/guide/env") + ); + assert_eq!( + documentation_url_for_command_path(&["config"]), + Some("https://viteplus.dev/guide/commit-hooks") + ); + } + + #[test] + fn render_help_doc_appends_documentation_footer() { + let output = render_help_doc(&HelpDoc { + usage: "vp demo", + summary: vec![], + sections: vec![], + documentation_url: Some("https://viteplus.dev/guide/demo"), + }); + + assert!(output.contains("Documentation: https://viteplus.dev/guide/demo")); + } } diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index f531d60c2c..84d1cc9bd9 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -4,7 +4,76 @@ import type { VoidZeroThemeConfig } from '@voidzero-dev/vitepress-theme'; import { extendConfig } from '@voidzero-dev/vitepress-theme/config'; import { defineConfig, type HeadConfig } from 'vitepress'; -// https://vitepress.dev/reference/site-config +const taskRunnerGuideItems = [ + { + text: 'Run', + link: '/guide/run', + }, + { + text: 'Task Caching', + link: '/guide/cache', + }, + { + text: 'Running Binaries', + link: '/guide/vpx', + }, +]; + +const guideSidebar = [ + { + text: 'Introduction', + items: [ + { text: 'Getting Started', link: '/guide/' }, + { text: 'Creating a Project', link: '/guide/create' }, + { text: 'Migrate to Vite+', link: '/guide/migrate' }, + { text: 'Installing Dependencies', link: '/guide/install' }, + { text: 'Environment', link: '/guide/env' }, + ], + }, + { + text: 'Develop', + items: [ + { text: 'Dev', link: '/guide/dev' }, + { + text: 'Check', + link: '/guide/check', + items: [ + { text: 'Lint', link: '/guide/lint' }, + { text: 'Format', link: '/guide/fmt' }, + ], + }, + { text: 'Test', link: '/guide/test' }, + ], + }, + { + text: 'Execute', + items: taskRunnerGuideItems, + }, + { + text: 'Build', + items: [ + { text: 'Build', link: '/guide/build' }, + { text: 'Pack', link: '/guide/pack' }, + ], + }, + { + text: 'Maintain', + items: [ + { text: 'Upgrading Vite+', link: '/guide/upgrade' }, + { text: 'Removing Vite+', link: '/guide/implode' }, + ], + }, + { + text: 'Workflow', + items: [ + { text: 'IDE Integration', link: '/guide/ide-integration' }, + { text: 'CI', link: '/guide/ci' }, + { text: 'Commit Hooks', link: '/guide/commit-hooks' }, + { text: 'Troubleshooting', link: '/guide/troubleshooting' }, + ], + }, +]; + export default extendConfig( defineConfig({ title: 'Vite+', @@ -35,7 +104,6 @@ export default extendConfig( defer: '', }, ], - // ["script", {}, "document.documentElement.setAttribute('data-theme', 'light')"], ], vite: { resolve: { @@ -51,665 +119,62 @@ export default extendConfig( nav: [ { text: 'Guide', - activeMatch: '/vite/guide/', - items: [ - { text: 'Vite Core', link: '/vite/guide/' }, - { text: 'Test', link: '/vite/guide/test/getting-started' }, - { text: 'Lint', link: '/vite/guide/lint/getting-started' }, - { text: 'Format', link: '/vite/guide/format/getting-started' }, - { text: 'Task Runner', link: '/vite/guide/task/getting-started' }, - { text: 'Library Bundler', link: '/lib/guide/getting-started' }, - { text: 'DevTools', link: '/guide/devtools/getting-started' }, - { text: 'Package Manager', link: '/guide/package-manager/getting-started' }, - ], + link: '/guide/', + activeMatch: '^/guide/', }, { text: 'Config', - activeMatch: '/config/', - items: [ - { text: 'Vite Core', link: '/config/' }, - { text: 'Test', link: '/config/test' }, - { text: 'Lint', link: '/config/lint' }, - { text: 'Format', link: '/config/format' }, - { text: 'Task Runner', link: '/vite/guide/task/config' }, - { text: 'Package Manager', link: '/config/package-manager' }, - ], + link: '/config/', + activeMatch: '^/config/', }, - { - text: 'APIs', - activeMatch: '/apis/', - items: [ - { text: 'Vite API', link: '/apis/' }, - { text: 'Environment API', link: '/apis/environment' }, - { text: 'Test API', link: '/apis/test' }, - { text: 'Lint API', link: '/apis/lint' }, - { text: 'Format API', link: '/apis/format' }, - { text: 'Task Runner API', link: '/apis/task-runner' }, - ], - }, - { - text: 'Plugins', - activeMatch: '/plugins/', - items: [ - { text: 'Vite Plugins', link: '/plugins/' }, - { text: 'Test Plugins', link: '/plugins/test' }, - { text: 'Lint Plugins', link: '/plugins/lint' }, - { text: 'Format Plugins', link: '/plugins/format' }, - { text: 'Task Runner Plugins', link: '/plugins/task-runner' }, - ], - }, - // { - // text: 'Test', - // activeMatch: '/plugins/', - // items: [ - // { text: 'Guide & API', link: '/test/guide/' }, - // { text: 'Config', link: '/test/config/' }, - // { text: 'Browser Mode', link: '/test/browser-mode/' }, - // ], - // }, - // { - // text: 'Format', - // activeMatch: '/plugins/', - // items: [ - // { text: 'Guide & API', link: '/test/guide/' }, - // { text: 'Config', link: '/test/config/' }, - // { text: 'Browser Mode', link: '/test/browser-mode/' }, - // ], - // }, { text: 'Resources', items: [ - { text: 'Team', link: 'https://voidzero.dev/team' }, - { text: 'Blog', link: 'https://voidzero.dev/blog' }, + { text: 'GitHub', link: 'https://github.com/voidzero-dev/vite-plus' }, { text: 'Releases', link: 'https://github.com/voidzero-dev/vite-plus/releases' }, { - items: [ - { - text: 'Awesome Vite+', - link: 'https://github.com/voidzero-dev/awesome-vite-plus', - }, - { - text: 'ViteConf', - link: 'https://viteconf.org', - }, - { - text: 'DEV Community', - link: 'https://dev.to/t/vite', - }, - { - text: 'Changelog', - link: 'https://github.com/voidzero-dev/vite-plus/releases', - }, - { - text: 'Contributing', - link: 'https://github.com/voidzero-dev/vite-plus/blob/main/CONTRIBUTING.md', - }, - ], - }, - ], - }, - ], - - sidebar: { - '/vite/guide/': { - base: '/vite/guide/', - items: [ - { - text: 'Introduction', - items: [ - { - text: 'Getting Started', - link: 'index', - }, - { - text: 'Monorepo', - link: 'monorepo', - }, - { - text: 'Philosophy', - link: 'philosophy', - }, - { - text: 'Why Vite+', - link: 'why', - }, - { - text: 'Migration', - link: 'migration', - }, - ], - }, - { - text: 'Vite Core', - items: [ - { - text: 'Features', - link: 'features', - }, - { - text: 'CLI', - link: 'cli', - }, - { - text: 'Using Plugins', - link: 'using-plugins', - }, - { - text: 'Dependency Pre-Bundling', - link: 'dependency-pre-bundling', - }, - { - text: 'Static Asset Handling', - link: 'static-asset-handling', - }, - { - text: 'Building for Production', - link: 'building-for-production', - }, - { - text: 'Deploying a Static Site', - link: 'deploying-a-static-site', - }, - { - text: 'Env Variables and Modes', - link: 'env-variables-and-modes', - }, - { - text: 'Server-Side Rendering', - link: 'server-side-rendering', - }, - { - text: 'Backend Integration', - link: 'backend-integration', - }, - { - text: 'Troubleshooting', - link: 'troubleshooting', - }, - { - text: 'Performance', - link: 'performance', - }, - { - text: 'Migration from vite@7+', - link: 'migration', - }, - ], - }, - { - text: 'Test', - items: [ - { - text: 'Getting Started', - link: '/guide/test/getting-started', - }, - { - text: 'Features', - link: '/guide/test/features', - }, - { - text: 'CLI', - link: '/guide/test/cli', - }, - { - text: 'Test Filtering', - link: '/guide/test/test-filtering', - }, - { - text: '...', - link: '/guide/test/dependency-pre-bundling', - }, - { - text: 'Migration from vitest', - link: '/guide/test/migration-from-vitest', - }, - ], - }, - { - text: 'Lint', - items: [ - { - text: 'Getting Started', - link: '/guide/lint/getting-started', - }, - { - text: 'Features', - link: '/guide/lint/features', - }, - { - text: 'CLI', - link: '/guide/lint/cli', - }, - { - text: '...', - link: '/guide/test/dependency-pre-bundling', - }, - { - text: 'Migration from oxlint', - link: '/guide/test/migration-from-oxlint', - }, - { - text: 'Migration from ESLint', - link: '/guide/test/migration-from-eslint', - }, - ], - }, - { - text: 'Format', - items: [ - { - text: 'Getting Started', - link: '/guide/format/getting-started', - }, - { - text: 'Features', - link: '/guide/format/features', - }, - { - text: 'CLI', - link: '/guide/format/cli', - }, - { - text: 'Migration from oxfmt', - link: '/guide/format/migration-from-oxfmt', - }, - { - text: 'Migration from Prettier', - link: '/guide/format/migration-from-prettier', - }, - ], - }, - { - text: 'Task Runner', - items: [ - { - text: 'Getting Started', - link: 'task/getting-started', - }, - { - text: 'Running Tasks', - link: 'task/running-tasks', - }, - { - text: 'Caching', - link: 'task/caching', - }, - { - text: 'CLI', - link: 'task/cli', - }, - { - text: 'Config', - link: 'task/config', - }, - ], - }, - { - text: 'Library Bundler', - items: [ - { - text: 'Getting Started', - link: '/guide/library/getting-started', - }, - { - text: 'Features', - link: '/guide/library/features', - }, - { - text: 'CLI', - link: '/guide/library/cli', - }, - { - text: 'Migration from tsdown', - link: '/guide/library/migration-from-tsdown', - }, - { - text: 'Migration from tsup', - link: '/guide/library/migration-from-tsup', - }, - { - text: 'Migration from esbuild', - link: '/guide/library/migration-from-esbuild', - }, - ], - }, - { - text: 'DevTools', - items: [ - { - text: 'Getting Started', - link: '/guide/devtools/getting-started', - }, - { - text: 'Features', - link: '/guide/library/features', - }, - { - text: 'CLI', - link: '/guide/devtools/cli', - }, - ], - }, - { - text: 'Package Manager', - items: [ - { - text: 'Getting Started', - link: '/guide/package-manager/getting-started', - }, - { - text: 'Features', - link: '/guide/package-manager/features', - }, - { - text: 'CLI', - link: '/guide/package-manager/cli', - }, - ], - }, - ], - }, - '/lib/guide/': { - base: '/lib/guide/', - items: [ - { - text: 'Library Bundler', - items: [ - { - text: 'Introduction', - link: 'introduction', - }, - { - text: 'Getting Started', - link: 'getting-started', - }, - { - text: 'Migration from tsdown', - link: '/guide/library/migration-from-tsdown', - }, - { - text: 'Migration from tsup', - link: '/guide/library/migration-from-tsup', - }, - { - text: 'Migration from esbuild', - link: '/guide/library/migration-from-esbuild', - }, - ], - }, - { - text: 'Options', - items: [ - { - text: 'Entry', - link: 'entry', - }, - { - text: 'Config File', - link: 'config-file', - }, - { - text: 'Declaration Files (dts)', - link: 'dts', - }, - ], - }, - { - text: 'Recipes', - items: [ - { - text: 'Vue Support', - link: 'vue-support', - }, - { - text: 'React Support', - link: 'react-support', - }, - { - text: 'Svelte Support', - link: 'svelte-support', - }, - ], - }, - { - text: 'Advanced', - items: [ - { - text: 'Plugins', - link: 'plugins', - }, - { - text: 'Hooks', - link: 'hooks', - }, - { - text: 'Rolldown Options', - link: 'rolldown-options', - }, - { - text: 'Programmatic Usage', - link: 'programmatic-usage', - }, - ], + text: 'Announcement', + link: 'https://voidzero.dev/posts/announcing-vite-plus-alpha', }, { - text: 'API Reference', - items: [ - { - text: 'Command Line Interface', - link: 'command-line-interface', - }, - { - text: 'Config Options', - link: 'config-options', - }, - { - text: 'Type Definitions', - items: [ - { - text: 'AttwOptions', - link: 'attributes-options', - }, - { - text: 'BuildContext', - link: 'build-context', - }, - ], - }, - ], + text: 'Contributing', + link: 'https://github.com/voidzero-dev/vite-plus/blob/main/CONTRIBUTING.md', }, ], }, + ], + sidebar: { + '/guide/': guideSidebar, '/config/': [ { - text: 'Vite Core', - items: [ - { - text: 'Configuring Vite+', - link: '/config/', - }, - { - text: 'Shared Options', - link: '/config/shared-options', - }, - { - text: 'Server Options', - link: '/config/server-options', - }, - { - text: 'Build Options', - link: '/config/build-options', - }, - { - text: 'Preview Options', - link: '/config/preview-options', - }, - { - text: 'Dep Optimization Options', - link: '/config/dep-optimization-options', - }, - { - text: 'SSR Options', - link: '/config/ssr-options', - }, - { - text: 'Worker Options', - link: '/config/worker-options', - }, - ], - }, - { - text: 'Test', + text: 'Configuration', items: [ - { - text: 'Configuring Test', - link: '/config/test', - }, - { - text: 'Test Options', - link: '/config/test-options', - }, - ], - }, - { - text: 'Lint', - items: [ - { - text: 'Configuring Lint', - link: '/config/lint', - }, - { - text: 'Lint Options', - link: '/config/lint-options', - }, - ], - }, - { - text: 'Task Runner', - items: [ - { - text: 'Configuring Task Runner', - link: '/vite/guide/task/config', - }, + { text: 'Configuring Vite+', link: '/config/' }, + { text: 'Run', link: '/config/run' }, + { text: 'Format', link: '/config/fmt' }, + { text: 'Lint', link: '/config/lint' }, + { text: 'Test', link: '/config/test' }, + { text: 'Build', link: '/config/build' }, + { text: 'Pack', link: '/config/pack' }, + { text: 'Staged', link: '/config/staged' }, ], }, ], - '/apis/': [ - { - text: 'Vite Core API', - items: [ - { - text: 'Plugin API', - link: '/apis/vite/plugin', - }, - { - text: 'HMR API', - link: '/apis/vite/hmr', - }, - { - text: 'JavaScript API', - link: '/apis/vite/javascript', - }, - ], - }, - { - text: 'Environment API', - items: [ - { - text: 'Introduction', - link: '/apis/environment/introduction', - }, - { - text: 'Environment Instances', - link: '/apis/environment/instances', - }, - { - text: 'Plugins', - link: '/apis/environment/plugins', - }, - { - text: 'Frameworks', - link: '/apis/environment/frameworks', - }, - { - text: 'Runtimes', - link: '/apis/environment/runtimes', - }, - ], - }, - { - text: 'Test API', - items: [ - { - text: 'Introduction', - link: '/apis/test/introduction', - }, - { - text: 'Plugin API', - link: '/apis/test/plugin', - }, - ], - }, - { - text: 'Lint API', - items: [ - { - text: 'Introduction', - link: '/apis/lint/introduction', - }, - { - text: 'Plugin API', - link: '/apis/lint/plugin', - }, - ], - }, - { - text: 'Format API', - items: [ - { - text: 'Introduction', - link: '/apis/format/introduction', - }, - { - text: 'Plugin API', - link: '/apis/format/plugin', - }, - ], - }, - { - text: 'Task Runner API', - items: [ - { - text: 'Introduction', - link: '/apis/task-runner/introduction', - }, - { - text: 'Plugin API', - link: '/apis/task-runner/plugin', - }, - ], - }, - ], - '/changes/': [], }, - socialLinks: [ { icon: 'github', link: 'https://github.com/voidzero-dev/vite-plus' }, { icon: 'x', link: 'https://x.com/voidzerodev' }, { icon: 'discord', link: 'https://discord.gg/cC6TEVFKSx' }, { icon: 'bluesky', link: 'https://bsky.app/profile/voidzero.dev' }, ], - outline: { level: [2, 3], }, - search: { provider: 'local', }, }, transformHead({ page, pageData }) { - // Remove .md suffix and replace index with empty string (to cover index.md) const url = 'https://viteplus.dev/' + page.replace(/\.md$/, '').replace(/index$/, ''); const canonicalUrlEntry: HeadConfig = [ diff --git a/docs/.vitepress/theme/components/Footer.vue b/docs/.vitepress/theme/components/Footer.vue index 4bb367932c..f3298acd2f 100644 --- a/docs/.vitepress/theme/components/Footer.vue +++ b/docs/.vitepress/theme/components/Footer.vue @@ -13,15 +13,7 @@ Take your team's productivity to the next level with Vite+
Rolldown -
  • import { Icon } from '@iconify/vue'; -import { ref, onMounted, onUnmounted } from 'vue'; +import { onMounted, onUnmounted, ref } from 'vue'; -const nav = [{ text: 'Docs', link: '/vite/guide' }]; +const nav = [{ text: 'Docs', link: '/guide' }]; -// Mobile menu state const mobileMenuOpen = ref(false); const expandedMobileItem = ref(null); -// Body scroll lock for mobile menu const lockBodyScroll = () => { const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth; document.body.style.overflow = 'hidden'; @@ -28,23 +26,18 @@ const unlockBodyScroll = () => { document.body.style.paddingRight = ''; }; -// Close mobile menu const closeMobileMenu = () => { mobileMenuOpen.value = false; expandedMobileItem.value = null; unlockBodyScroll(); }; -// Handle keyboard navigation const handleKeydown = (e: KeyboardEvent) => { - if (e.key === 'Escape') { - if (mobileMenuOpen.value) { - closeMobileMenu(); - } + if (e.key === 'Escape' && mobileMenuOpen.value) { + closeMobileMenu(); } }; -// Toggle mobile menu const toggleMobileMenu = () => { mobileMenuOpen.value = !mobileMenuOpen.value; if (mobileMenuOpen.value) { @@ -67,20 +60,20 @@ onUnmounted(() => {