Files
PX4-Autopilot/docs/package.json
Hamish Willee 3b8019f37a fix(docs): Use vitepress plugin from NPM for dynamic nav bar (#27498)
* fix(docs): bypass VitePress router interception in DynamicNav links

VitePress installs a global click interceptor that catches same-origin
<a> clicks and routes them through Vue Router. Cross-version links
(e.g. /v1.17/en/ from /main/en/) share the origin but are separate
deployments, so Vue Router fails to resolve them and navigation is
silently swallowed. Fix by calling window.location.href directly with
@click.prevent on all nav links.

Signed-off-by: Hamish Willee <hamishwillee@gmail.com>

* refactor(docs): use VitePress internal nav components in DynamicNav

Replace the hand-rolled dropdown/link rendering with VitePress's own
VPNavBarMenuLink, VPNavBarMenuGroup, VPNavScreenMenuLink, and
VPNavScreenMenuGroup. This removes ~140 lines of custom CSS and all
manual click/flyout handling; VitePress styles and VPFlyout behaviour
are inherited for free.

The navigation bug (same-origin links swallowed by Vue Router) is also
fixed by this approach: VPLink classifies any https:// href as external
and renders a plain <a> tag, bypassing the router interceptor entirely.

Remote URL and localStorage key are now read from themeConfig
(dynamicNavUrl, dynamicNavCacheKey) so the component can be dropped
into any VitePress repo with just a config change.

Signed-off-by: Hamish Willee <hamishwillee@gmail.com>

* refactor(docs): derive DynamicNav cache key from URL by default

Use the remote URL as the localStorage key when dynamicNavCacheKey is
not set. This avoids the need to declare a key in config, keeps the
key unique per data source automatically, and means all deployed
versions of a site (same origin, different base paths) naturally share
one cache entry — which is the desired behaviour.

Signed-off-by: Hamish Willee <hamishwillee@gmail.com>

* chore(docs): remove redundant nav:[] from themeConfig

VitePress renders no menu items when nav is omitted, so the explicit
empty array adds no value now that all items come from DynamicNav.

Signed-off-by: Hamish Willee <hamishwillee@gmail.com>

* fix(docs): restore display:flex on DynamicNav bar wrapper

Removing the scoped styles during the VitePress-internal-components
refactor also removed the flex layout on the wrapper div, causing nav
items to stack vertically instead of in a row.

Signed-off-by: Hamish Willee <hamishwillee@gmail.com>

* refactor(docs): replace local DynamicNav with vp-dynamic-nav npm package

Removes the in-tree DynamicNav.vue and wires up the published
vp-dynamic-nav package instead. navbar.json is imported in config.mjs
and passed as dynamicNavInitial so it remains the single source of
truth for both the initial render and the remote fetch target.

Signed-off-by: Hamish Willee <hamishwillee@gmail.com>

---------

Signed-off-by: Hamish Willee <hamishwillee@gmail.com>
2026-05-29 09:05:11 +10:00

37 lines
1.4 KiB
JSON

{
"name": "px4_user_guide",
"version": "1.0.1",
"repository": "https://github.com/PX4/px4_user_guide.git",
"license": "CC-BY-4.0",
"scripts": {
"docs:dev": "vitepress dev .",
"docs:build": "yarn docs:build_ubuntu",
"docs:buildwin": "set NODE_OPTIONS=--max_old_space_size=8192 && set CI=true && vitepress build .",
"docs:build_ubuntu": "NODE_OPTIONS='--max-old-space-size=8192' vitepress build .",
"docs:preview": "vitepress preview .",
"docs:sitemap": "python3 ./scripts/gen_sitemap.py",
"docs:gen_alt_sidebar_ubuntu": "python3 ./scripts/gen_alt_sidebar.py",
"docs:get_alt_sidebar_windows": "python ./scripts/gen_alt_sidebar.py",
"start": "yarn docs:dev",
"linkcheck": "markdown_link_checker_sc -r .. -d docs -e en -i assets -u docs.px4.io",
"build_docs_metadata_ubuntu": "(cd .. && Tools/ci/metadata_sync.sh --generate && Tools/ci/metadata_sync.sh --sync) && echo 'NOTE: These metadata changes are for local testing only and do not need to be merged.'"
},
"dependencies": {
"@red-asuka/vitepress-plugin-tabs": "0.0.4",
"lite-youtube-embed": "^0.3.4",
"markdown-it-mathjax3": "^4.3.2",
"medium-zoom": "^1.1.0",
"open-editor": "^5.0.0",
"vitepress": "^1.6.3",
"vp-dynamic-nav": "^0.0.1",
"vue3-tabs-component": "^1.3.7"
},
"devDependencies": {
"prettier": "^3.8.3"
},
"resolutions": {
"markdown-it": "^14.1.1",
"esbuild": "^0.25.0"
}
}