rsshub
Version:
Make RSS Great Again!
190 lines (183 loc) • 3.87 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import { t as ViewType } from "./types-D84BRIt4.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import "./parse-date-BrP7mxXf.mjs";
import "./cache-Bo__VnGm.mjs";
import "./render-BQo6B4tL.mjs";
import { a as variables, i as getList, r as getData, t as baseUrl } from "./utils-BYCmah7P.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
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/:innerSharedContent?/:dateSort?",
example: "/daily/popular",
view: ViewType.Articles,
radar: [{ source: ["app.daily.dev/popular"] }],
parameters: {
innerSharedContent: {
description: "Where to Fetch inner Shared Posts instead of original",
default: "false",
options: [{
value: "false",
label: "False"
}, {
value: "true",
label: "True"
}]
},
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.parseInt(ctx.req.query("limit"), 10) : 15;
const innerSharedContent = ctx.req.param("innerSharedContent") ? JSON.parse(ctx.req.param("innerSharedContent")) : false;
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
}
}), innerSharedContent, 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 };