UNPKG

rsshub

Version:
57 lines (55 loc) 1.91 kB
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs"; import { t as config } from "./config-C37vj7VH.mjs"; import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import { t as art } from "./render-BQo6B4tL.mjs"; import path from "node:path"; //#region lib/routes/daily/utils.ts init_esm_shims(); 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 ofetch_default(`${baseUrl}/onboarding`)).match(/"buildId":"(.*?)"/)[1]; }, config.cache.routeExpire, false); const getData = async (graphqlQuery, source = false) => { const response = await ofetch_default(gqlUrl, { method: "POST", body: graphqlQuery }); return source ? response.data.source : response.data.page.edges; }; const render = (data) => art(path.join(__dirname, "templates/posts-9f06bc1e.art"), data); const getList = (edges, innerSharedContent, dateSort) => edges.map(({ node }) => { let link; let title; if (innerSharedContent && node.type === "share") { link = node.sharedPost.permalink; title = node.sharedPost.title; } else { link = node.commentsPermalink ?? node.permalink; title = node.title; } return { id: node.id, title, link, guid: node.permalink, description: render({ image: node.image, content: node.contentHtml?.replaceAll("\n", "<br>") ?? node.summary }), author: node.author?.name, itunes_item_image: node.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 };