glyphnav/astro

Watch the address bar. Current path: /glyphnav/astro/docs/

Docs

Install the package — Astro stays a peer dependency:
pnpm add glyphnav
Attach once in a shared layout's bundled client script:
---
import { ClientRouter } from 'astro:transitions';
---
<head><ClientRouter /></head>
<script>
  import { navigate } from 'astro:transitions/client';
  import { attachGlyphnav } from 'glyphnav/astro';

  // Bundled scripts run once, even across ClientRouter swaps.
  const glyph = attachGlyphnav(navigate, { duration: 250 });
  // await glyph.navigate('/about/', { history: 'replace' });
</script>
Or animate only explicit navigation and selected links:
const glyph = attachGlyphnav(navigate, { intercept: 'none' });
await glyph.navigate('/about/', { history: 'replace', state: { from: 'docs' } });

// Opt one anchor into animation:
const unlink = glyph.link(document.querySelector('a'));
unlink();
glyph.detach(); // remove listeners and cancel animation
Animation and interception options:
attachGlyphnav(navigate, {
  duration: 250,         // total animation time in milliseconds
  effect: 'scramble',    // 'decode' or 'scramble'
  commit: 'before',      // 'after' animates before navigating
  intercept: 'links',    // 'none' animates only explicit calls
  scope: 'tail',         // preserve the common path prefix
  animatePopState: true, // opt into browser back/forward animation
});

Served under the /astro base with Astro's ClientRouter. attachGlyphnav(navigate) animates eligible links and awaits Astro's real navigation. The title link returns to the picker with a full page load.