UNPKG

rsshub

Version:
47 lines (46 loc) 1.96 kB
import { t as rofetch } from "./ofetch-C3ts-Hud.mjs"; import { t as config } from "./config-CCmw1BNE.mjs"; import { t as parseDate } from "./parse-date-Cr0wQjV_.mjs"; import { t as cache_default } from "./cache-BkqOokyU.mjs"; import { Fragment, jsx, jsxs } from "hono/jsx/jsx-runtime"; import { renderToString } from "hono/jsx/dom/server"; import { raw } from "hono/html"; //#region lib/routes/daily/utils.tsx const baseUrl = "https://app.daily.dev"; const gqlUrl = "https://api.daily.dev/graphql"; const variables = { version: 54, loggedIn: false }; const getBuildId = () => cache_default.tryGet("daily:buildId", async () => { return (await rofetch(`${baseUrl}/onboarding`)).match(/"buildId":"(.*?)"/)[1]; }, config.cache.routeExpire, false); const getData = async (graphqlQuery, source = false) => { const response = await rofetch(gqlUrl, { method: "POST", body: graphqlQuery }); return source ? response.data.source : response.data.page.edges; }; const render = ({ image, content }) => renderToString(/* @__PURE__ */ jsxs(Fragment, { children: [image ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("img", { src: image }), /* @__PURE__ */ jsx("br", {})] }) : null, content ? raw(content) : null] })); const getList = (edges, dateSort) => edges.map(({ node }) => { const post = node.type === "share" ? node.sharedPost : node; return { id: node.id, title: post.title, link: node.commentsPermalink ?? node.permalink, guid: node.permalink, description: render({ image: post.image?.includes("/public/Placeholder") ? void 0 : post.image, content: node.contentHtml?.replaceAll("\n", "<br>") ?? post.summary }), author: node.author?.name, itunes_item_image: post.image, pubDate: dateSort ? parseDate(node.createdAt) : "", upvotes: node.numUpvotes, comments: node.numComments, category: node.tags }; }); //#endregion export { variables as a, getList as i, getBuildId as n, getData as r, baseUrl as t };