Skip to content

Commit

Permalink
feat: move redirect routes to own section of sitemap MP-880
Browse files Browse the repository at this point in the history
  • Loading branch information
emuvente committed Oct 2, 2024
1 parent 2e8b68e commit ece45b6
Showing 1 changed file with 34 additions and 13 deletions.
47 changes: 34 additions & 13 deletions src/pages/UiSiteMap/RouteListing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<h2 class="tw-mb-4">
Prod Routes
</h2>
<ul class="tw-list-disc tw-list-inside">
<ul class="tw-list-disc tw-list-inside tw-mb-4">
<li v-for="route in prodRoutes" :key="route.path">
<router-link :to="route.path">
<!-- eslint-disable-next-line -->
Expand All @@ -17,7 +17,7 @@
<h2 class="tw-mb-4">
Dev Routes
</h2>
<ul class="tw-list-disc tw-list-inside">
<ul class="tw-list-disc tw-list-inside tw-mb-4">
<li v-for="route in devRoutes" :key="route.path">
<router-link :to="route.path">
<!-- eslint-disable-next-line -->
Expand All @@ -26,6 +26,24 @@
</li>
</ul>
</div>
<div v-if="redirectRoutes.length">
<h2 class="tw-mb-4">
Redirects
</h2>
<ul class="tw-list-disc tw-list-inside tw-mb-4">
<li v-for="route in redirectRoutes" :key="route.path">
<router-link :to="route.path">
<!-- eslint-disable-next-line -->
{{ route.path.replace('/','') }} <small v-if="route.name !== 'no-name'">({{ route.name }})</small>
</router-link>
&rarr;
<router-link :to="route.redirect">
<!-- eslint-disable-next-line -->
{{ route.redirect }}
</router-link>
</li>
</ul>
</div>
</div>
</template>

Expand All @@ -38,25 +56,28 @@ export default {
return {
devRoutes: [],
prodRoutes: [],
redirectRoutes: [],
};
},
created() {
this.$router.options.routes = _orderBy(this.$router.options.routes, [route => route.path.toLowerCase()]);
const defaults = {
name: 'no-name',
path: 'no-path',
status: 'no-status',
};
this.$router.options.routes.forEach(route => {
const routeWithDefaults = { ...defaults, ...route };
if (route.redirect) {
return this.redirectRoutes.push(routeWithDefaults);
}
if (route.status === 'dev') {
this.devRoutes.push({
name: route.name ? route.name : 'no-name',
path: route.path ? route.path : 'no-path',
status: route.status ? route.status : 'no-status',
});
} else {
this.prodRoutes.push({
name: route.name ? route.name : 'no-name',
path: route.path ? route.path : 'no-path',
status: route.status ? route.status : 'no-status',
});
return this.devRoutes.push(routeWithDefaults);
}
this.prodRoutes.push(routeWithDefaults);
});
},
};
Expand Down

0 comments on commit ece45b6

Please sign in to comment.