rsshub
Version:
Make RSS Great Again!
121 lines (116 loc) • 2.77 kB
JavaScript
import "./types-DNj6Etbg.mjs";
import { a as variables, i as getList, r as getData, t as baseUrl } from "./utils-Cb3-YQMg.mjs";
//#region lib/routes/daily/discussed.ts
const query = `
query MostDiscussedFeed($first: Int, $supportedTypes: [String!] = ["article", "share", "freeform"]) {
page: mostDiscussedFeed(first: $first, supportedTypes: $supportedTypes) {
...FeedPostConnection
}
}
fragment FeedPostConnection on PostConnection {
edges {
node {
...FeedPost
contentHtml
}
}
}
fragment FeedPost on Post {
...SharedPostInfo
type
sharedPost {
title
summary
image
permalink
}
}
fragment SharedPostInfo on Post {
id
title
image
readTime
permalink
commentsPermalink
summary
createdAt
numUpvotes
numComments
author {
...UserShortInfo
}
tags
}
fragment UserShortInfo on User {
id
name
image
permalink
username
bio
}
`;
const route = {
path: "/discussed/:period?/:dateSort?",
example: "/daily/discussed/30",
view: 0,
radar: [{ source: ["app.daily.dev/discussed"] }],
name: "Most Discussed",
maintainers: ["Rjnishant530"],
handler,
url: "app.daily.dev/discussed",
parameters: {
dateSort: {
description: "Sort posts by publication date instead of popularity",
default: "true",
options: [{
value: "false",
label: "False"
}, {
value: "true",
label: "True"
}]
},
period: {
description: "Period of Lookup",
default: "7",
options: [
{
value: "7",
label: "Last Week"
},
{
value: "30",
label: "Last Month"
},
{
value: "365",
label: "Last Year"
}
]
}
}
};
async function handler(ctx) {
const limit = ctx.req.query("limit") ? Number(ctx.req.query("limit")) : 20;
const dateSort = ctx.req.param("dateSort") ? JSON.parse(ctx.req.param("dateSort")) : true;
const period = ctx.req.param("period") ? Number(ctx.req.param("period")) : 7;
return {
title: "Real-time discussions in the developer community | daily.dev",
link: `${baseUrl}/posts/discussed`,
item: getList(await getData({
query,
variables: {
...variables,
first: limit,
period
}
}), dateSort),
description: "Stay on top of real-time developer discussions on daily.dev. Join conversations happening now and engage with the most active community members.",
logo: `${baseUrl}/favicon-32x32.png`,
icon: `${baseUrl}/favicon-32x32.png`,
language: "en-us"
};
}
//#endregion
export { route };