Skip to content

Commit

Permalink
improve: Add middleware to support Drupal tabs redirect (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
vloss3 authored Jul 9, 2024
1 parent c2fcdb9 commit 44507d7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions playground/middleware/redirect.global.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export default defineNuxtRouteMiddleware((to, from) => {
const config = useRuntimeConfig().public.drupalCe

switch (true) {
case /^\/((en|de)\/)?user.*$/.test(to.path):
case /^\/((en|de)\/)?admin.*$/.test(to.path):
case /^\/((en|de)\/)?(node\/(add|[^/]+\/(edit|delete|revisions|translations))|entity_clone\/node\/[^/]+)/.test(
to.path,
):
case /^\/((en|de)\/)?node\/[^/]+\/layout$/.test(to.path):
return navigateTo(`${config.drupalBaseUrl}${to.fullPath}`, {
external: true,
redirectCode: 301,
})
}
})

0 comments on commit 44507d7

Please sign in to comment.