Skip to content

Commit

Permalink
fix(blueprints): no more namespace & tag in blueprint URI
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-mulier-p committed Oct 24, 2024
1 parent 8ac187c commit 08a0182
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 22 deletions.
15 changes: 1 addition & 14 deletions components/blueprints/Lists.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,6 @@ if(route.query.tags) {
}
if(route.query.q) searchQuery.value = route.query.q;
if (!activeTags.value) {
const id = route.params.slug?.split('-')[0];
const {data: blueprintInformations} = await useAsyncData('blueprints-informations', () => {
return $fetch(`/api/blueprint?query=${id}`)
})
activeTags.value = [{ name: 'All tags' }];
if (blueprintInformations && blueprintInformations.value) {
let tag = tags.value.find(f => f?.id == blueprintInformations.value.page.tags[0]);
await navigateTo(`/blueprints/${tag.id}/${route.params.slug}`);
}
}
const { data: blueprintsData, error } = await useAsyncData('blueprints', () => {
return $fetch(`${config.public.apiUrl}/blueprints/versions/latest?page=${currentPage.value}&size=${itemsPerPage.value}${route.query.tags ? `&tags=${activeTags.value.map(tag => tag.id).join(',')}` : ''}${route.query.q ? `&q=${searchQuery.value}` : ''}`)
})
Expand All @@ -131,8 +119,7 @@ const changePage = (pageNo) => {
};
const generateCardHref = (blueprint) => {
let tag = tags.value.find(f => f?.id == blueprint.tags[0]);
return `/blueprints/${tag.id}/${blueprint.id}`
return `/blueprints/${blueprint.id}`
}
let timer;
Expand Down
3 changes: 1 addition & 2 deletions components/blueprints/Related.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
},
methods: {
generateCardHref (blueprint) {
let tag = this.tags.find(f => f?.id == blueprint.tags[0]);
return `/blueprints/${tag.id}/${blueprint.id}`
return `/blueprints/${blueprint.id}`
}
},
}
Expand Down
4 changes: 2 additions & 2 deletions components/use-cases/engineers/ExploreBlueprints.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
const generateCardHref = (blueprint) => {
let tag = tags.value.find(f => f?.id == blueprint.tags[0]);
if (!tag || !tag.id) {
return `/blueprints/unknown/${blueprint.id}`;
return `/blueprints/${blueprint.id}`;
}
return `/blueprints/${tag.id}/${blueprint.id}`
return `/blueprints/${blueprint.id}`
}
if (blueprintsData.value) {
blueprints.value = blueprintsData.value.results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,15 @@
const description = ref()
const flowAsMd = ref("")
const categorySlug = route.fullPath?.split('/')[2];
const {data: tags} = await useAsyncData('blueprints-tags', () => {
return $fetch(`${config.public.apiUrl}/blueprints/versions/latest/tags`)
})
const activeTag = tags.value.find(f => f?.name?.toLowerCase() == categorySlug.replace('-', ' '));
const {data: blueprintInformations, error} = await useAsyncData('blueprints-informations', () => {
return $fetch(`/api/blueprint?query=${route.params.id}`)
})
if ((error && error.value) || (!activeTag && categorySlug !== 'all-tags')) {
if (error && error.value) {
throw createError({statusCode: 404, message: 'Page not found', data: error, fatal: true})
}
Expand Down

0 comments on commit 08a0182

Please sign in to comment.