UNPKG

dailyhot-api

Version:
33 lines (32 loc) 1.12 kB
import { get } from "../utils/getData.js"; import { getTime } from "../utils/getTime.js"; export const handleRoute = async (_, noCache) => { const listData = await getList(noCache); const routeData = { name: "ifanr", title: "爱范儿", type: "快讯", description: "15秒了解全球新鲜事", link: "https://www.ifanr.com/digest/", total: listData.data?.length || 0, ...listData, }; return routeData; }; const getList = async (noCache) => { const url = "https://sso.ifanr.com/api/v5/wp/buzz/?limit=20&offset=0"; const result = await get({ url, noCache }); const list = result.data.objects; return { ...result, data: list.map((v) => ({ id: v.id, title: v.post_title, desc: v.post_content, timestamp: getTime(v.created_at), hot: v.like_count || v.comment_count, url: v.buzz_original_url || `https://www.ifanr.com/${v.post_id}`, mobileUrl: v.buzz_original_url || `https://www.ifanr.com/digest/${v.post_id}`, })), }; };