Skip to content

Normalize Slidev subpage routing for standalone decks#8

Merged
harrybin merged 4 commits into
mainfrom
copilot/fix-routing-to-subpages-again
Jul 1, 2026
Merged

Normalize Slidev subpage routing for standalone decks#8
harrybin merged 4 commits into
mainfrom
copilot/fix-routing-to-subpages-again

Conversation

Copilot AI commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Standalone decks published under a deck-specific base path were generating duplicated subroutes during in-deck navigation, e.g. /aiops-Mainteance-mit-KI/aiops-Mainteance-mit-KI/2. The result was broken slide navigation even though the correct deck root still existed.

  • Routing fix

    • Add a small router shim in setup/main.ts to normalize navigation targets before they reach Vue Router.
    • Strip the configured router base from router.push / router.replace targets when Slidev passes base-prefixed paths.
  • Boundary-safe normalization

    • Only remove exact path-prefix matches at segment boundaries.
    • Preserve unrelated paths that merely start with similar characters.
  • Scope

    • Centralized in shared Slidev app setup, so the fix applies to standalone decks without touching individual presentation files.
const stripBase = (path: string) => {
  if (hasPathPrefix(path, normalizedBase))
    return path.slice(normalizedBase.length) || "/"
  return path
}

router.push = wrapNavigationMethod(router.push.bind(router))
router.replace = wrapNavigationMethod(router.replace.bind(router))

Copilot AI linked an issue Jul 1, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix routing issues for subpages Normalize Slidev subpage routing for standalone decks Jul 1, 2026
Copilot AI requested a review from harrybin July 1, 2026 13:29
@harrybin

harrybin commented Jul 1, 2026

Copy link
Copy Markdown
Owner

we upgraded the version of slidev. it looks like that routing behabior chaaged. Previously I could only define a routeAlias for singe pages and from there on all navigation was relative, so that was done for the first slide.
In the previous fix attempt you discovered that there is now also a setting on deck-level to set a alies.
Thake this as hint, maybe you also find documentation online.
Remember the result is hosted on github pages.
@copilot
Does your patch still apply with thtis information?

@harrybin harrybin marked this pull request as ready for review July 1, 2026 13:31
@harrybin

harrybin commented Jul 1, 2026

Copy link
Copy Markdown
Owner

@copilot please regard my last commwnt

Copilot AI commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

we upgraded the version of slidev. it looks like that routing behabior chaaged. Previously I could only define a routeAlias for singe pages and from there on all navigation was relative, so that was d...

Yes — with the current Slidev behavior, the shim still applies.

I checked the current Slidev docs/source: routeAlias is still a slide URL alias, not a replacement for the deck base path. In this repo each standalone deck is already deployed on GitHub Pages with --base "/<deck>/" from build.sh, so using the deck slug as an alias would add another path segment instead of fixing the doubled one.

The duplicated URL comes from navigation targets that already include the base before Vue Router resolves them. Normalizing router.push / router.replace in setup/main.ts is what prevents /aiops-Mainteance-mit-KI/aiops-Mainteance-mit-KI/2 while keeping the GitHub Pages subpath hosting intact.

@harrybin harrybin merged commit c147f97 into main Jul 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

routing to subpages got messed up

2 participants