Files
RSSHub/lib/routes/ikea/cn/utils.ts
T
DIYgod 83e701b592 feat: compile ts through tsdown (#18908)
* feat: build ts via tsdown

* feat: exec tsdown

* fix

* fix

* fix

* feat: use tsdown shims

* chore: run rolldown lifecycle script

* fix: use shims

---------
2025-04-22 22:29:11 +08:00

40 lines
1.1 KiB
TypeScript

import { art } from '@/utils/render';
import md5 from '@/utils/md5';
import path from 'node:path';
const generateRequestHeaders = () => {
const now = Math.round(Date.now() / 1000);
return {
'X-Client-Platform': 'WechatMiniprogram',
'X-Client-DeviceId': md5(now.toString()),
};
};
const generateProductItem = (product) => {
const {
productFullId,
name,
productType,
measureText,
priceDisplay: { currentPrice, originalPrice },
images,
} = product;
const isFamilyOffer = currentPrice && originalPrice;
return {
title: `${name} ${productType} - \u{000A5}${currentPrice}`,
description: art(path.join(__dirname, '../templates/cn/product.art'), {
isFamilyOffer,
name,
productType,
measureText,
currentPrice,
originalPrice,
images: images.map((image) => image.url),
}),
link: `https://www.ikea.cn/cn/zh/p/${productFullId}`,
};
};
export { generateRequestHeaders, generateProductItem };