Skip to content

Commit

Permalink
Add new image[auto commit]
Browse files Browse the repository at this point in the history
  • Loading branch information
VovaStelmashchuk committed Sep 10, 2024
1 parent de77a88 commit 18c9b0a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion features/filters/description.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ class DescriptionBuilder {
description += await this.addGoodsDescriptionIfExist(filters['goods']);
description += await this.addGlasswareDescriptionIfExist(filters['glassware']);

return description.trim().length > 0 && description.trim() !== 'коктейлі' ? description.trim() : null;
// trim string remove command and spaces at start and end of string
description = description.trim().replace(/(^\s*,)|(,\s*$)/g, '').replace(/^./, char => char.toUpperCase()).trim();

description = description.trim().length > 0 && description.trim() !== 'коктейлі' ? description.trim() : null;
return description;
}

async addGlasswareDescriptionIfExist(glasswareSlugs) {
Expand Down
8 changes: 5 additions & 3 deletions utils/image.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Function to build image objects
require('dotenv').config();

const imageUrlStart = process.env.IMAGE_URL_START;

const buildImages = (id, type) => {
const domain = "https://newimages.mixdrinks.org/files";
const types = {
COCKTAIL: "cocktails",
ITEM: "goods"
Expand All @@ -15,7 +17,7 @@ const buildImages = (id, type) => {

return formats.flatMap(format =>
sizes.map(size => ({
srcset: `${domain}/${types[type]}/${id}/${size.imageSize}/${id}.${format}`,
srcset: `${imageUrlStart}/${types[type]}/${id}/${size.imageSize}/${id}.${format}`,
media: `screen and (min-width: ${size.responseSize}px)`,
type: `image/${format}`
}))
Expand Down

0 comments on commit 18c9b0a

Please sign in to comment.