diff --git a/docs/docs/documentation/getting-started/features.md b/docs/docs/documentation/getting-started/features.md index 8e4aa6258..a068ceea5 100644 --- a/docs/docs/documentation/getting-started/features.md +++ b/docs/docs/documentation/getting-started/features.md @@ -139,6 +139,9 @@ Below is a list of all valid merge fields: - ${id} - ${slug} - ${url} +- ${servings} +- ${yieldQuantity} +- ${yieldText} To add, modify, or delete Recipe Actions, visit the Data Management page (more on that below). diff --git a/frontend/components/Domain/Recipe/RecipeContextMenu.vue b/frontend/components/Domain/Recipe/RecipeContextMenu.vue index a0a47832c..b6165feff 100644 --- a/frontend/components/Domain/Recipe/RecipeContextMenu.vue +++ b/frontend/components/Domain/Recipe/RecipeContextMenu.vue @@ -371,7 +371,7 @@ export default defineComponent({ const groupRecipeActionsStore = useGroupRecipeActions(); async function executeRecipeAction(action: GroupRecipeActionOut) { - const response = await groupRecipeActionsStore.execute(action, props.recipe); + const response = await groupRecipeActionsStore.execute(action, props.recipe, props.recipeScale); if (action.actionType === "post") { if (!response?.error) { diff --git a/frontend/composables/use-group-recipe-actions.ts b/frontend/composables/use-group-recipe-actions.ts index 915f92547..d2b37a803 100644 --- a/frontend/composables/use-group-recipe-actions.ts +++ b/frontend/composables/use-group-recipe-actions.ts @@ -49,7 +49,10 @@ export const useGroupRecipeActions = function ( return `${window.location.origin}/g/${groupSlug}/shared/r/${token}`; } - async function parseRecipeActionUrl(url: string, recipe: Recipe): Promise { + async function parseRecipeActionUrl(url: string, recipe: Recipe, recipeScale: number): Promise { + const recipeServings = (recipe.recipeServings || 1) * recipeScale; + const recipeYieldQuantity = (recipe.recipeYieldQuantity || 1) * recipeScale; + /* eslint-disable no-template-curly-in-string */ const shareLinkRegex = /\$\{share-link-expires-seconds-[0-9]+\}/g; const group = (await api.groups.getOne(recipe.groupId || "")).data; @@ -83,11 +86,14 @@ export const useGroupRecipeActions = function ( .replace("${url}", window.location.href) .replace("${id}", recipe.id || "") .replace("${slug}", recipe.slug || "") + .replace("${servings}", recipeServings.toString()) + .replace("${yieldQuantity}", recipeYieldQuantity.toString()) + .replace("${yieldText}", recipe.recipeYield || "") /* eslint-enable no-template-curly-in-string */ }; - async function execute(action: GroupRecipeActionOut, recipe: Recipe): Promise> { - const url = await parseRecipeActionUrl(action.url, recipe); + async function execute(action: GroupRecipeActionOut, recipe: Recipe, recipeScale: number): Promise> { + const url = await parseRecipeActionUrl(action.url, recipe, recipeScale); switch (action.actionType) { case "link":