Files
Nishant Singh 95904cf1be feat(route): add daily.dev (#12616)
* feat(route): add daily.dev

* refactor(route):review changes #12616

* Update docs/en/social-media.md

* refactor(route):review changes #12616

---------
2023-06-07 14:14:30 +08:00

84 lines
1.5 KiB
JavaScript

const { getData, getList, getRedirectedLink } = require('./utils.js');
const variables = {
version: 11,
ranking: 'POPULARITY',
first: 15,
};
const query = `
query AnonymousFeed(
$first: Int
$ranking: Ranking
$version: Int
$supportedTypes: [String!] = ["article","share","freeform"]
) {
page: anonymousFeed(
first: $first
ranking: $ranking
version: $version
supportedTypes: $supportedTypes
) {
...FeedPostConnection
}
}
fragment FeedPostConnection on PostConnection {
edges {
node {
...FeedPost
}
}
}
fragment FeedPost on Post {
...SharedPostInfo
}
fragment SharedPostInfo on Post {
id
title
image
readTime
permalink
summary
createdAt
numUpvotes
numComments
author {
...UserShortInfo
}
tags
}
fragment UserShortInfo on User {
id
name
image
permalink
username
bio
}
`;
const graphqlQuery = {
query,
variables,
};
module.exports = async (ctx) => {
const baseUrl = 'https://app.daily.dev/popular';
const data = await getData(graphqlQuery);
const list = getList(data);
const items = await getRedirectedLink(list);
ctx.state.data = {
title: 'Popular',
link: baseUrl,
item: items,
description: 'Popular Posts on Daily.dev',
logo: 'https://app.daily.dev/favicon-32x32.png',
icon: 'https://app.daily.dev/favicon-32x32.png',
language: 'en-us',
};
};