Skip to content

Commit

Permalink
add og image to cocktails
Browse files Browse the repository at this point in the history
  • Loading branch information
VovaStelmashchuk committed Sep 14, 2024
1 parent b516b2a commit 72be610
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 6 additions & 1 deletion features/cocktail/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { buildImages } = require("../../utils/image");
const { buildImages, buildOgImage } = require("../../utils/image");
const { getCocktailBySlug } = require("../../database/cocktail");

async function getFullCocktailBySlug(slug) {
Expand Down Expand Up @@ -55,6 +55,10 @@ async function getFullCocktailBySlug(slug) {
ratting = null;
}

const meta = {
ogImage: buildOgImage(cocktail.id, 'COCKTAIL'),
}

return {
id: cocktail.id,
slug: cocktail.slug,
Expand All @@ -63,6 +67,7 @@ async function getFullCocktailBySlug(slug) {
rating: ratting,
ratingCount: cocktail.ratingCount,
receipt: cocktail.recipe,
meta: meta,
images: cocktailImages,
goods: goods,
tools: glassware.concat(tools),
Expand Down
12 changes: 11 additions & 1 deletion utils/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ const buildImages = (id, type) => {
);
};

const buildOgImage = (id, type) => {
const types = {
COCKTAIL: "cocktails",
ITEM: "goods"
};

return `${imageUrlStart}/${types[type]}/${id}/256/${id}.jpg`;
};

module.exports = {
buildImages
buildImages,
buildOgImage,
}

0 comments on commit 72be610

Please sign in to comment.