fix(route): Epic Games Store - items containing non-free games (#13637)

This commit is contained in:
KotaHv
2023-10-25 21:09:43 +08:00
committed by GitHub
parent fbfdba6457
commit eac391ea2b
2 changed files with 11 additions and 10 deletions
+10 -10
View File
@@ -24,7 +24,9 @@ module.exports = async (ctx) => {
(item) =>
item.promotions &&
item.promotions.promotionalOffers &&
item.promotions.promotionalOffers[0] &&
item.promotions.promotionalOffers.length &&
item.promotions.promotionalOffers[0].promotionalOffers[0].discountSetting.discountType === 'PERCENTAGE' &&
item.promotions.promotionalOffers[0].promotionalOffers[0].discountSetting.discountPercentage === 0 &&
dayjs(item.promotions.promotionalOffers[0].promotionalOffers[0].startDate) <= now &&
dayjs(item.promotions.promotionalOffers[0].promotionalOffers[0].endDate) > now
)
@@ -32,15 +34,11 @@ module.exports = async (ctx) => {
let link = `${rootUrl}/${locale}/p/`;
let contentUrl = `${contentBaseUrl}/products/`;
let isBundles = false;
item.categories.some((category) => {
if (category.path === 'bundles') {
link = `${rootUrl}/${locale}/bundles/`;
isBundles = true;
contentUrl = `${contentBaseUrl}/bundles/`;
return true;
}
return false;
});
if (item.categories.some((category) => category.path === 'bundles')) {
link = `${rootUrl}/${locale}/bundles/`;
isBundles = true;
contentUrl = `${contentBaseUrl}/bundles/`;
}
const linkSlug = item.catalogNs.mappings.length > 0 ? item.catalogNs.mappings[0].pageSlug : item.offerMappings.length > 0 ? item.offerMappings[0].pageSlug : item.productSlug ? item.productSlug : item.urlSlug;
link += linkSlug;
contentUrl += linkSlug;
@@ -61,6 +59,7 @@ module.exports = async (ctx) => {
}
return false;
});
const endDate = dayjs(item.promotions.promotionalOffers[0].promotionalOffers[0].endDate).toISOString();
return {
title: item.title,
author: item.seller.name,
@@ -68,6 +67,7 @@ module.exports = async (ctx) => {
description: art(path.join(__dirname, 'templates/description.art'), {
description,
image,
endDate,
}),
pubDate: parseDate(item.promotions.promotionalOffers[0].promotionalOffers[0].startDate),
};
@@ -1,2 +1,3 @@
<p>{{ description }}</p>
<img src="{{ image }}">
<p>Free Now to {{ endDate }}</p>