mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-10-27 08:14:30 -04:00
fix: Restore recipe meta for non-logged-in users (#6286)
This commit is contained in:
@@ -19,20 +19,21 @@ import type { Recipe } from "~/lib/api/types/recipe";
|
|||||||
const $auth = useMealieAuth();
|
const $auth = useMealieAuth();
|
||||||
const { isOwnGroup } = useLoggedInState();
|
const { isOwnGroup } = useLoggedInState();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const title = ref(route.meta?.title ?? "");
|
const title = ref(route.meta?.title as string || "");
|
||||||
useSeoMeta({ title });
|
useSeoMeta({ title });
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const slug = route.params.slug as string;
|
const slug = route.params.slug as string;
|
||||||
|
|
||||||
const recipe = ref<Recipe | null>(null);
|
const recipe = ref<Recipe | null>(null);
|
||||||
if (isOwnGroup.value) {
|
function loadRecipe() {
|
||||||
const { recipe: data } = useRecipe(slug);
|
const { recipe: data } = useRecipe(slug);
|
||||||
watch(data, (value) => {
|
watch(data, (value) => {
|
||||||
recipe.value = value;
|
recipe.value = value;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
async function loadPublicRecipe() {
|
||||||
const groupSlug = computed(() => route.params.groupSlug as string || $auth.user.value?.groupSlug || "");
|
const groupSlug = computed(() => route.params.groupSlug as string || $auth.user.value?.groupSlug || "");
|
||||||
const api = usePublicExploreApi(groupSlug.value);
|
const api = usePublicExploreApi(groupSlug.value);
|
||||||
const { data } = await useAsyncData(useAsyncKey(), async () => {
|
const { data } = await useAsyncData(useAsyncKey(), async () => {
|
||||||
@@ -47,6 +48,13 @@ else {
|
|||||||
recipe.value = data.value;
|
recipe.value = data.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isOwnGroup.value) {
|
||||||
|
loadRecipe();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
onMounted(loadPublicRecipe);
|
||||||
|
}
|
||||||
|
|
||||||
whenever(
|
whenever(
|
||||||
() => recipe.value,
|
() => recipe.value,
|
||||||
() => {
|
() => {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ const router = useRouter();
|
|||||||
const recipeId = route.params.id as string;
|
const recipeId = route.params.id as string;
|
||||||
const api = usePublicApi();
|
const api = usePublicApi();
|
||||||
|
|
||||||
const title = ref(route.meta?.title ?? "");
|
const title = ref(route.meta?.title as string ?? "");
|
||||||
useSeoMeta({
|
useSeoMeta({
|
||||||
title,
|
title,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user