Skip to content

Commit

Permalink
Generalize route regex
Browse files Browse the repository at this point in the history
  • Loading branch information
awolosz committed Sep 1, 2024
1 parent cc43a2d commit fc9b60c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,40 @@ import NotFoundView from '@/views/NotFoundView.vue'
import Section from '@/components/Section.vue'
import { useSynopsisStore } from "@/stores/SynopsisStore"

const languageOptionsRegex = "(hu|en)"
const translationOptionsRegex = "(SZIT|ESV)"

const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/:language(hu|en)/:translation(SZIT|ESV)',
path: `/:language${languageOptionsRegex}/:translation${translationOptionsRegex}`,
alias: '/',
name: 'synopsis',
component: SynopsisView
},
{
path: '/:language(hu|en)/about',
path: `/:language${languageOptionsRegex}/about`,
name: 'about',
component: AboutView
},
{
path: '/:language(hu|en)/:translation(SZIT|ESV)/index',
path: `/:language${languageOptionsRegex}/:translation${translationOptionsRegex}/index`,
name: 'index',
component: IndexView
},
{
path: '/:language(hu|en)/sources',
path: `/:language${languageOptionsRegex}/sources`,
name: 'sources',
component: SourcesView
},
{
path: '/:language(hu|en)/contact',
path: `/:language${languageOptionsRegex}/contact`,
name: 'contact',
component: ContactView
},
{
path: '/:language(hu|en)/:translation(SZIT|ESV)/:id([1-9]|[1-9]\\d|[12]\\d{2}|3[0-5]\\d|36[0-7])',
path: `/:language${languageOptionsRegex}/:translation${translationOptionsRegex}/:id([1-9]|[1-9]\\d|[12]\\d{2}|3[0-5]\\d|36[0-7])`,
name: 'section',
component: Section,
props: true
Expand Down

0 comments on commit fc9b60c

Please sign in to comment.