fix: Restore recipe meta for non-logged-in users (#6286)

This commit is contained in:
Michael Genson
2025-09-29 10:33:18 -05:00
committed by GitHub
parent d1824affff
commit 83bf21b947
2 changed files with 12 additions and 4 deletions

View File

@@ -19,20 +19,21 @@ import type { Recipe } from "~/lib/api/types/recipe";
const $auth = useMealieAuth();
const { isOwnGroup } = useLoggedInState();
const route = useRoute();
const title = ref(route.meta?.title ?? "");
const title = ref(route.meta?.title as string || "");
useSeoMeta({ title });
const router = useRouter();
const slug = route.params.slug as string;
const recipe = ref<Recipe | null>(null);
if (isOwnGroup.value) {
function loadRecipe() {
const { recipe: data } = useRecipe(slug);
watch(data, (value) => {
recipe.value = value;
});
}
else {
async function loadPublicRecipe() {
const groupSlug = computed(() => route.params.groupSlug as string || $auth.user.value?.groupSlug || "");
const api = usePublicExploreApi(groupSlug.value);
const { data } = await useAsyncData(useAsyncKey(), async () => {
@@ -47,6 +48,13 @@ else {
recipe.value = data.value;
}
if (isOwnGroup.value) {
loadRecipe();
}
else {
onMounted(loadPublicRecipe);
}
whenever(
() => recipe.value,
() => {

View File

@@ -25,7 +25,7 @@ const router = useRouter();
const recipeId = route.params.id as string;
const api = usePublicApi();
const title = ref(route.meta?.title ?? "");
const title = ref(route.meta?.title as string ?? "");
useSeoMeta({
title,
});