From 55a1d130a048fff87f96cff56d804ad2325e8662 Mon Sep 17 00:00:00 2001 From: Corentin Thomasset Date: Mon, 15 Mar 2021 12:49:38 +0100 Subject: [PATCH] fix: prevented routes duplicates du to i18n --- CHANGELOG.md | 1 + mixins/tool-routes.mixin.ts | 3 ++- nuxt.config.js | 4 +++- pages/index.vue | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4496cc10..762a9be9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added [/how-to-report-bug-or-request](/how-to-report-bug-or-request) route to explain how to report bug and request features +- Added i18n support ## 1.7.0 - [feat] [Crontab friendly generator](https://it-tools.tech/crontab-generator) diff --git a/mixins/tool-routes.mixin.ts b/mixins/tool-routes.mixin.ts index f9917713..46a04f04 100644 --- a/mixins/tool-routes.mixin.ts +++ b/mixins/tool-routes.mixin.ts @@ -9,7 +9,7 @@ export class ToolRoutesMixin extends Vue { toolRoutesSections : {[key: string]: ToolRouteConfig[]} = {} async created() { - const routes = this.$router.options.routes?.filter(r => r.meta?.isTool) || [] + const routes = this.$router.options.routes?.filter((r1, i, a) => r1.meta?.isTool && a.findIndex(r2 => r2.path.split('/').pop() === r1.path.split('/').pop()) === i) || [] const flat: ToolRouteConfig[] = [] const sections: { [key: string]: ToolRouteConfig[] } = {} @@ -17,6 +17,7 @@ export class ToolRoutesMixin extends Vue { if ('component' in route) { // @ts-ignore const component = await route.component() + const routeConfig = {...route, config: component.options.methods.config()} as ToolRouteConfig flat.push(routeConfig) diff --git a/nuxt.config.js b/nuxt.config.js index 6cbdd789..68c4461c 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -83,7 +83,9 @@ export default { i18n: { vueI18nLoader: true, - locales: ['en'] + locales: ['en'], + defaultLocale: 'en', + strategy: 'prefix_and_default' }, // Build Configuration (https://go.nuxtjs.dev/config-build) diff --git a/pages/index.vue b/pages/index.vue index 51e95e52..81d95453 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -3,7 +3,7 @@

Yolo

- + {{ item.config.icon }} - +