iles
Version:
Vite & Vue powered static site generator with partial hydration
12 lines (11 loc) • 436 B
JavaScript
import { useSSRContext } from 'vue';
import { useRoute } from 'vue-router';
export function useIslandsForPath() {
const context = useSSRContext();
if (!context)
throw new Error('SSR context not found when rendering islands.');
if (!context.islandsByPath)
throw new Error('SSR context is missing islands.');
const currentRoute = useRoute();
return (context.islandsByPath[currentRoute.path] ||= []);
}