rsshub
Version:
Make RSS Great Again!
154 lines (149 loc) • 3.58 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/popular.ts
const query = `
query AnonymousFeed($loggedIn: Boolean! = false, $first: Int, $after: String, $ranking: Ranking, $version: Int, $supportedTypes: [String!] = ["article", "share", "freeform", "video:youtube", "collection"]) {
page: anonymousFeed(first: $first, after: $after, ranking: $ranking, version: $version, supportedTypes: $supportedTypes) {
...FeedPostConnection
}
}
fragment FeedPostConnection on PostConnection {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
...FeedPost
contentHtml
...UserPost @include(if: $loggedIn)
}
}
}
fragment FeedPost on Post {
...FeedPostInfo
sharedPost {
id
title
summary
image
readTime
permalink
commentsPermalink
createdAt
type
tags
source {
id
handle
permalink
image
}
slug
clickbaitTitleDetected
}
trending
feedMeta
collectionSources {
handle
image
}
numCollectionSources
updatedAt
slug
}
fragment FeedPostInfo on Post {
id
title
image
readTime
permalink
commentsPermalink
createdAt
commented
bookmarked
views
numUpvotes
numComments
summary
bookmark {
remindAt
}
author {
id
name
image
username
permalink
}
type
tags
source {
id
handle
name
permalink
image
type
}
userState {
vote
flags {
feedbackDismiss
}
}
slug
clickbaitTitleDetected
}
fragment UserPost on Post {
read
upvoted
commented
bookmarked
downvoted
}
`;
const route = {
path: "/popular/:dateSort?",
example: "/daily/popular",
view: 0,
radar: [{ source: ["app.daily.dev/popular"] }],
parameters: { dateSort: {
description: "Sort posts by publication date instead of popularity",
default: "true",
options: [{
value: "false",
label: "False"
}, {
value: "true",
label: "True"
}]
} },
name: "Popular",
maintainers: ["Rjnishant530"],
handler,
url: "app.daily.dev/popular"
};
async function handler(ctx) {
const link = `${baseUrl}/posts`;
const limit = ctx.req.query("limit") ? Number(ctx.req.query("limit")) : 15;
const dateSort = ctx.req.param("dateSort") ? JSON.parse(ctx.req.param("dateSort")) : true;
return {
title: "Popular posts on daily.dev",
link,
item: getList(await getData({
query,
variables: {
...variables,
ranking: "POPULARITY",
first: limit
}
}), dateSort),
description: "daily.dev is the easiest way to stay updated on the latest programming news. Get the best content from the top tech publications on any topic you want.",
logo: `${baseUrl}/favicon-32x32.png`,
icon: `${baseUrl}/favicon-32x32.png`,
language: "en-us"
};
}
//#endregion
export { route };