1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-02 20:15:24 +02:00

fix: set meta description and image for shared recipes (#1635)

This commit is contained in:
Philipp Fischbeck 2022-09-10 19:29:21 +02:00 committed by GitHub
parent 25c40b8abf
commit 1c938cb835
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 18 deletions

View file

@ -1,29 +1,31 @@
import { Ref } from "@nuxtjs/composition-api";
import { useStaticRoutes } from "~/composables/api";
import { Recipe } from "~/types/api-types/recipe";
export interface RecipeMeta {
title?: string;
metaImage?: string;
mainImage?: string;
meta: Array<any>;
__dangerouslyDisableSanitizers: Array<string>;
script: Array<any>;
}
export const useRecipeMeta = (recipe: Ref<Recipe | null>): (() => RecipeMeta) => {
return () => {
const imageURL = "";
export const useRecipeMeta = () => {
const { recipeImage } = useStaticRoutes();
function recipeMeta(recipe: Ref<Recipe | null>): RecipeMeta {
const imageURL = recipeImage(recipe?.value?.id ?? "");
return {
title: recipe?.value?.name,
mainImage: imageURL,
meta: [
{ hid: "og:title", property: "og:title", content: recipe?.value?.name || "Recipe" },
{
hid: "og:desc",
hid: "og:description",
property: "og:description",
content: recipe?.value?.description ?? "",
},
{
hid: "og-image",
hid: "og:image",
property: "og:image",
content: imageURL,
},
@ -52,4 +54,5 @@ export const useRecipeMeta = (recipe: Ref<Recipe | null>): (() => RecipeMeta) =>
],
};
};
return { recipeMeta };
};