@flue3/router
Advanced tools
+4
-2
@@ -7,10 +7,12 @@ import { createRouter, createWebHistory, createMemoryHistory, } from 'vue-router'; | ||
| import { createRoutesMiddleware } from './middleware/createRoutesMiddleware.js'; | ||
| import { proceedUncertainModule } from 'flue3/lib/utils/proceedUncertainModule.js'; | ||
| export * from 'vue-router'; | ||
| export const createRouterPlugin = definePlugin(async ({ appContext, inject, onAfterEntry, }, options) => { | ||
| const routes = await proceedUncertainModule(options.routes); | ||
| const layouts = await proceedUncertainModule(options.layouts); | ||
| const router = createRouter({ | ||
| routes: [...options.routes, ...pluginRoutes], | ||
| routes: [...routes, ...pluginRoutes], | ||
| scrollBehavior: options.scrollBehavior, | ||
| history: appContext.isServer ? createMemoryHistory() : createWebHistory(), | ||
| }); | ||
| const layouts = options.layouts ?? {}; | ||
| inject('router', router); | ||
@@ -17,0 +19,0 @@ inject('layouts', layouts); |
+6
-2
@@ -8,5 +8,9 @@ import { Component } from 'vue'; | ||
| export interface RouterPluginOptions { | ||
| routes: RouteRecordRaw[]; | ||
| layouts?: LayoutComponentsRecord; | ||
| routes: (() => RouteRecordRaw[] | Promise<RouteRecordRaw[] | { | ||
| default: RouteRecordRaw[]; | ||
| }>) | RouteRecordRaw[]; | ||
| layouts?: (() => LayoutComponentsRecord | Promise<LayoutComponentsRecord | { | ||
| default: LayoutComponentsRecord; | ||
| }>) | LayoutComponentsRecord; | ||
| scrollBehavior?: RouterScrollBehavior; | ||
| } |
+1
-1
| { | ||
| "name": "@flue3/router", | ||
| "version": "0.0.13-dev.0", | ||
| "version": "0.0.14-dev.0", | ||
| "description": "flue3 <head> tag manager plugin", | ||
@@ -5,0 +5,0 @@ "author": "FL3NKEY", |
9583
4.16%230
2.68%