In my Nuxt3 project, I have a page whose Prismic blocks change order when changing languages....
The page is as follows: https://dev.adngroup.com/en/negotiation-notebooks
if I display the page in French or English via a refresh of the page (eg: F5), the blocks are displayed in the correct order. On the other hand, if I change the language via the flag at the top left, the bottom block is at the top....
Here is my code:
page file :
<script setup lang="ts">
import { components } from "~/slices";
const { locale } = useI18n();
const config = useRuntimeConfig();
const prismic = usePrismic();
const { data: page } = useAsyncData("[pagecarnetsnegociation]", () =>
prismic.client.getSingle("pagecarnetsnegociation", {
lang: locale.value === "en" ? "en-gb" : "fr-fr",
}),
);
</script>
<template>
<SliceZone wrapper="main" :slices="page?.data.slices ?? []" :components="components" />
</template>
slice file of the last block :
<script setup lang="ts">
import * as prismic from "@prismicio/client";
import { type Content } from "@prismicio/client";
const { client } = usePrismic();
const { locale } = useI18n();
// The array passed to `getSliceComponentProps` is purely optional.
// Consider it as a visual hint for you when templating your slice.
defineProps(
getSliceComponentProps<Content.CarnetsNegociationSlice>(["slice", "index", "slices", "context"]),
);
// https://prismic.io/docs/technical-reference/prismicio-client
const {
data: carnets,
status,
error,
} = await useLazyAsyncData("prismicCarnetsNegociation", async () => {
const carnets = await client.getByType("carnetnegociation", {
lang: locale.value === "en" ? "en-gb" : "fr-fr",
orderings: {
field: "my.carnetnegociation.date",
direction: "desc",
},
});
return carnets;
});
</script>
<template>
<v-container id="containerCarnetsNegociation">
<div v-if="error">{{ error }}</div>
<div v-else-if="status == 'pending'" class="text-center">
<v-progress-circular indeterminate color="primary"></v-progress-circular>
</div>
<div v-else-if="carnets && carnets.results.length > 0">
<div class="d-flex flex-wrap justify-center">
<v-card
v-for="carnet in carnets.results"
width="340px"
flat=""
rounded="0"
:to="localePath(`/carnet-negociation/${carnet?.uid}`)"
class="ma-2 ma-md-4 ma-lg-6 ma-xl-8"
>
<div class="headerCard px-4 py-10">
<h3>{{ carnet.data.titre }}</h3>
<div class="mt-5 ouvrir">{{ slice.primary.ouvrir_le_carnet }}</div>
</div>
<v-img :src="carnet.data.photo.url" width="100%" height="250px" cover></v-img>
</v-card>
</div>
</div>
</v-container>
</template>
I searched for the problem for hours but couldn't find it...