File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -14,13 +14,13 @@ export const RouteInjectionPlugin = (nuxt: Nuxt) =&
8F1F
gt; createUnplugin(() => {
14
14
return isVue ( id , { type : [ 'template' , 'script' ] } )
15
15
} ,
16
16
transform ( code ) {
17
- if ( ! INJECTION_SINGLE_RE . test ( code ) ) { return }
17
+ if ( ! INJECTION_SINGLE_RE . test ( code ) || code . includes ( '_ctx._.provides[__nuxt_route_symbol' ) ) { return }
18
18
19
19
let replaced = false
20
20
const s = new MagicString ( code )
21
21
s . replace ( INJECTION_RE , ( ) => {
22
22
replaced = true
23
- return '_ctx._.provides[__nuxt_route_symbol]'
23
+ return '( _ctx._.provides[__nuxt_route_symbol] || _ctx.$route) '
24
24
} )
25
25
if ( replaced ) {
26
26
s . prepend ( 'import { PageRouteSymbol as __nuxt_route_symbol } from \'#app/components/injections\';\n' )
You can’t perform that action at this time.
0 commit comments