From c562f835d3c77ae908334ed2c522dcf2743b87da Mon Sep 17 00:00:00 2001 From: Meow <197331664+Meo597@users.noreply.github.com> Date: Wed, 10 Jun 2026 05:55:43 +0800 Subject: [PATCH] VitePress: Add `activeMatch` for nav menus --- .vitepress/menus/nav.en.mts | 59 +++++++++++++++++++++++++++++------ .vitepress/menus/nav.mts | 62 +++++++++++++++++++++++++++++++------ .vitepress/menus/nav.ru.mts | 59 +++++++++++++++++++++++++++++------ 3 files changed, 150 insertions(+), 30 deletions(-) diff --git a/.vitepress/menus/nav.en.mts b/.vitepress/menus/nav.en.mts index 19e27f84..6ea69b80 100644 --- a/.vitepress/menus/nav.en.mts +++ b/.vitepress/menus/nav.en.mts @@ -4,26 +4,65 @@ export const nav: DefaultTheme.Config["nav"] = [ { text: "Homepage", link: "/en" }, { text: "Configuration Guide", + activeMatch: "^/en/config/", items: [ - { text: "Feature Details", link: "/en/config/features/" }, - { text: "Basic Configuration", link: "/en/config/" }, - { text: "Inbound Protocols", link: "/en/config/inbounds/" }, - { text: "Outbound Protocols", link: "/en/config/outbounds/" }, - { text: "Transport Configuration", link: "/en/config/transports/" } + { + text: "Feature Details", + link: "/en/config/features/", + activeMatch: "^/en/config/features/" + }, + { + text: "Basic Configuration", + link: "/en/config/", + activeMatch: "^/en/config/[^/]*$" + }, + { + text: "Inbound Protocols", + link: "/en/config/inbounds/", + activeMatch: "^/en/config/inbounds/" + }, + { + text: "Outbound Protocols", + link: "/en/config/outbounds/", + activeMatch: "^/en/config/outbounds/" + }, + { + text: "Transport Configuration", + link: "/en/config/transports/", + activeMatch: "^/en/config/transports/" + } ] }, { text: "Usage Guide", + activeMatch: "^/en/document/", items: [ - { text: "Quick Start", link: "/en/document/" }, + { + text: "Quick Start", + link: "/en/document/", + activeMatch: "^/en/document/[^/]*$" + }, { text: "Absolute Beginner's Plain Guide", - link: "/en/document/level-0/" + link: "/en/document/level-0/", + activeMatch: "^/en/document/level-0/" }, - { text: "Beginner Skills", link: "/en/document/level-1/" }, - { text: "Advanced Skills", link: "/en/document/level-2/" } + { + text: "Beginner Skills", + link: "/en/document/level-1/", + activeMatch: "^/en/document/level-1/" + }, + { + text: "Advanced Skills", + link: "/en/document/level-2/", + activeMatch: "^/en/document/level-2/" + } ] }, - { text: "Developer Guide", link: "/en/development/" }, + { + text: "Developer Guide", + link: "/en/development/", + activeMatch: "^/en/development/" + }, { text: "Sponsor & Donation & NFTs", link: "/en/about/sponsor.md" } ] diff --git a/.vitepress/menus/nav.mts b/.vitepress/menus/nav.mts index e7f09b64..53b85dac 100644 --- a/.vitepress/menus/nav.mts +++ b/.vitepress/menus/nav.mts @@ -4,23 +4,65 @@ export const nav: DefaultTheme.Config["nav"] = [ { text: "首页", link: "/" }, { text: "配置指南", + activeMatch: "^/config/", items: [ - { text: "特性详解", link: "/config/features/" }, - { text: "基础配置", link: "/config/" }, - { text: "入站协议", link: "/config/inbounds/" }, - { text: "出站协议", link: "/config/outbounds/" }, - { text: "传输配置", link: "/config/transports/" } + { + text: "特性详解", + link: "/config/features/", + activeMatch: "^/config/features/" + }, + { + text: "基础配置", + link: "/config/", + activeMatch: "^/config/[^/]*$" + }, + { + text: "入站协议", + link: "/config/inbounds/", + activeMatch: "^/config/inbounds/" + }, + { + text: "出站协议", + link: "/config/outbounds/", + activeMatch: "^/config/outbounds/" + }, + { + text: "传输配置", + link: "/config/transports/", + activeMatch: "^/config/transports/" + } ] }, { text: "使用指南", + activeMatch: "^/document/", items: [ - { text: "快速入门", link: "/document/" }, - { text: "小小白白话文", link: "/document/level-0/" }, - { text: "入门技巧", link: "/document/level-1/" }, - { text: "进阶技巧", link: "/document/level-2/" } + { + text: "快速入门", + link: "/document/", + activeMatch: "^/document/[^/]*$" + }, + { + text: "小小白白话文", + link: "/document/level-0/", + activeMatch: "^/document/level-0/" + }, + { + text: "入门技巧", + link: "/document/level-1/", + activeMatch: "^/document/level-1/" + }, + { + text: "进阶技巧", + link: "/document/level-2/", + activeMatch: "^/document/level-2/" + } ] }, - { text: "开发指南", link: "/development/" }, + { + text: "开发指南", + link: "/development/", + activeMatch: "^/development/" + }, { text: "赞助 & 捐款 & NFTs", link: "/about/sponsor.md" } ] diff --git a/.vitepress/menus/nav.ru.mts b/.vitepress/menus/nav.ru.mts index 44e613c2..0fb4f05e 100644 --- a/.vitepress/menus/nav.ru.mts +++ b/.vitepress/menus/nav.ru.mts @@ -4,26 +4,65 @@ export const nav: DefaultTheme.Config["nav"] = [ { text: "Главная", link: "/ru" }, { text: "Описание функций", + activeMatch: "^/ru/config/", items: [ - { text: "Обзор", link: "/ru/config/features/" }, - { text: "Базовая конфигурация", link: "/ru/config/" }, - { text: "Входящие подключения", link: "/ru/config/inbounds/" }, - { text: "Исходящие подключения", link: "/ru/config/outbounds/" }, - { text: "Конфигурация транспорта", link: "/ru/config/transports/" } + { + text: "Обзор", + link: "/ru/config/features/", + activeMatch: "^/ru/config/features/" + }, + { + text: "Базовая конфигурация", + link: "/ru/config/", + activeMatch: "^/ru/config/[^/]*$" + }, + { + text: "Входящие подключения", + link: "/ru/config/inbounds/", + activeMatch: "^/ru/config/inbounds/" + }, + { + text: "Исходящие подключения", + link: "/ru/config/outbounds/", + activeMatch: "^/ru/config/outbounds/" + }, + { + text: "Конфигурация транспорта", + link: "/ru/config/transports/", + activeMatch: "^/ru/config/transports/" + } ] }, { text: "Руководство по использованию", + activeMatch: "^/ru/document/", items: [ - { text: "Быстрый старт", link: "/ru/document/" }, + { + text: "Быстрый старт", + link: "/ru/document/", + activeMatch: "^/ru/document/[^/]*$" + }, { text: "Простыми словами", - link: "/ru/document/level-0/" + link: "/ru/document/level-0/", + activeMatch: "^/ru/document/level-0/" }, - { text: "Базовые навыки", link: "/ru/document/level-1/" }, - { text: "Продвинутые навыки", link: "/ru/document/level-2/" } + { + text: "Базовые навыки", + link: "/ru/document/level-1/", + activeMatch: "^/ru/document/level-1/" + }, + { + text: "Продвинутые навыки", + link: "/ru/document/level-2/", + activeMatch: "^/ru/document/level-2/" + } ] }, - { text: "Руководство разработчика", link: "/ru/development/" }, + { + text: "Руководство разработчика", + link: "/ru/development/", + activeMatch: "^/ru/development/" + }, { text: "Sponsor & Donation & NFTs", link: "/ru/about/sponsor.md" } ]