Skip to content

Commit

Permalink
Merge pull request #22 from netwerk-digitaal-erfgoed/fix/GH-21
Browse files Browse the repository at this point in the history
Fix: Navigation issues
  • Loading branch information
aabelmann authored Nov 4, 2024
2 parents af70b28 + 57be935 commit 52a995d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
1 change: 0 additions & 1 deletion nuxt/components/Atoms/Image.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
</template>

<script setup lang="ts">
const config = useRuntimeConfig();
const { supportIIIF } = storeToRefs(useFlixStore());
const props = withDefaults(
defineProps<{
Expand Down
6 changes: 3 additions & 3 deletions nuxt/components/Atoms/Navigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<script setup lang="ts">
const router = useRouter();
const { $navigate } = useNuxtApp();
const { currentFlix, isPreview } = useFlixStore();
const { currentFlix, isPreview } = storeToRefs(useFlixStore());
const props = withDefaults(
defineProps<{
Expand Down Expand Up @@ -37,10 +37,10 @@ const route = computed(() => {
});
const animateNavigation = () => {
if (isPreview) {
if (isPreview.value) {
return;
}
return $navigate(route.href, props.direction);
return $navigate(route.value, props.direction);
};
</script>

Expand Down
16 changes: 8 additions & 8 deletions nuxt/middleware/redirect-without-artwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ export default defineNuxtRouteMiddleware(to => {
const artworkStore = useArtworkStore();
const currentArtwork = artworkStore.findBySlug(artwork);

// If we have a current artwork, do nothing
if (currentArtwork) {
return;
}

// Note: We add the flix here since it's not going through AtomsNavigation
return navigateTo({
name: 'flix-category',
params: {
flix: currentFlix!.id,
category,
},
});
// If we have a currentFlix and a category, navigate to that
if (currentFlix && category) {
return navigateTo(`${currentFlix!.uri}/${category}`, { external: true });
}

// Worst case scenario, navigate to the home page
return '/';
});
11 changes: 7 additions & 4 deletions nuxt/server/api/images/[...].get.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
export default defineEventHandler((event) => {
export default defineEventHandler(event => {
const {
public: { backendUrl },
} = useRuntimeConfig();
const url = `${backendUrl}/images/${event.context.params._}`;
return event.$fetch(url);
})
const url = `${backendUrl}/images/${event.context.params!._}`;
// Note use the normal fetch instead of $fetch, so 302 from strapi are correctly handled
return fetch(url, {
redirect: 'manual',
});
});
4 changes: 2 additions & 2 deletions nuxt/stores/flix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const useFlixStore = defineStore('flix', () => {
const currentFlix = ref<Flix>();
const currentToken = ref<string>();
const currentViewport = ref<PreviewMediaQuery>('laptop');
const isPreview = ref(true);
const isPreview = ref(false);

/**
* Computed Properties
Expand Down Expand Up @@ -39,7 +39,7 @@ export const useFlixStore = defineStore('flix', () => {
// Reset the values back to default
currentFlix.value = undefined;
currentToken.value = undefined;
isPreview.value = true;
isPreview.value = false;
currentViewport.value = 'laptop';

// Also clean up other stores
Expand Down

0 comments on commit 52a995d

Please sign in to comment.