fix(route/daily): remove innerSharedContent parameter (#22786)

This commit is contained in:
Tony 2026-07-22 04:43:03 +08:00 committed by GitHub
parent a0a388b51b
commit 2c5929347a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 30 additions and 85 deletions

View File

@ -21,6 +21,13 @@ const query = /* GraphQL */ `
fragment FeedPost on Post {
...SharedPostInfo
type
sharedPost {
title
summary
image
permalink
}
}
fragment SharedPostInfo on Post {
@ -51,7 +58,7 @@ const query = /* GraphQL */ `
`;
export const route: Route = {
path: '/discussed/:period?/:innerSharedContent?/:dateSort?',
path: '/discussed/:period?/:dateSort?',
example: '/daily/discussed/30',
view: ViewType.Articles,
radar: [
@ -64,14 +71,6 @@ export const route: Route = {
handler,
url: 'app.daily.dev/discussed',
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',
@ -94,7 +93,6 @@ export const route: Route = {
async function handler(ctx) {
const limit = ctx.req.query('limit') ? Number(ctx.req.query('limit')) : 20;
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;
const period = ctx.req.param('period') ? Number(ctx.req.param('period')) : 7;
@ -108,7 +106,7 @@ async function handler(ctx) {
period,
},
});
const items = getList(data, innerSharedContent, dateSort);
const items = getList(data, dateSort);
return {
title: 'Real-time discussions in the developer community | daily.dev',

View File

@ -29,6 +29,7 @@ const query = /* GraphQL */ `
sharedPost {
id
title
summary
image
readTime
permalink
@ -110,7 +111,7 @@ const query = /* GraphQL */ `
`;
export const route: Route = {
path: '/popular/:innerSharedContent?/:dateSort?',
path: '/popular/:dateSort?',
example: '/daily/popular',
view: ViewType.Articles,
radar: [
@ -119,14 +120,6 @@ export const route: Route = {
},
],
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',
@ -145,7 +138,6 @@ export const route: Route = {
async function handler(ctx) {
const link = `${baseUrl}/posts`;
const limit = ctx.req.query('limit') ? Number(ctx.req.query('limit')) : 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;
const data = await getData({
@ -156,7 +148,7 @@ async function handler(ctx) {
first: limit,
},
});
const items = getList(data, innerSharedContent, dateSort);
const items = getList(data, dateSort);
return {
title: 'Popular posts on daily.dev',

View File

@ -42,6 +42,7 @@ const sourceFeedQuery = /* GraphQL */ `
sharedPost {
id
title
summary
image
readTime
permalink
@ -121,18 +122,10 @@ const sourceFeedQuery = /* GraphQL */ `
`;
export const route: Route = {
path: '/source/:sourceId/:innerSharedContent?',
path: '/source/:sourceId',
example: '/daily/source/hn',
parameters: {
sourceId: 'The source id',
innerSharedContent: {
description: 'Where to Fetch inner Shared Posts instead of original',
default: 'false',
options: [
{ value: 'false', label: 'False' },
{ value: 'true', label: 'True' },
],
},
},
radar: [
{
@ -148,7 +141,6 @@ export const route: Route = {
async function handler(ctx) {
const sourceId = ctx.req.param('sourceId');
const limit = ctx.req.query('limit') ? Number(ctx.req.query('limit')) : 10;
const innerSharedContent = ctx.req.param('innerSharedContent') ? JSON.parse(ctx.req.param('innerSharedContent')) : false;
const link = `${baseUrl}/sources/${sourceId}`;
const buildId = await getBuildId();
@ -172,7 +164,7 @@ async function handler(ctx) {
loggedIn: false,
},
});
return getList(edges, innerSharedContent, true);
return getList(edges, true);
},
config.cache.routeExpire,
false

View File

@ -107,6 +107,7 @@ const query = /* GraphQL */ `
sharedPost {
id
title
summary
image
readTime
permalink
@ -188,19 +189,9 @@ const query = /* GraphQL */ `
`;
export const route: Route = {
path: '/squads/:squads/:innerSharedContent?',
path: '/squads/:squads',
example: '/daily/squads/watercooler',
view: ViewType.Articles,
parameters: {
innerSharedContent: {
description: 'Where to Fetch inner Shared Posts instead of original',
default: 'false',
options: [
{ value: 'false', label: 'False' },
{ value: 'true', label: 'True' },
],
},
},
radar: [
{
source: ['app.daily.dev/squads/:squads'],
@ -214,7 +205,6 @@ export const route: Route = {
async function handler(ctx) {
const limit = ctx.req.query('limit') ? Number(ctx.req.query('limit')) : 20;
const innerSharedContent = ctx.req.param('innerSharedContent') ? JSON.parse(ctx.req.param('innerSharedContent')) : false;
const squads = ctx.req.param('squads');
const link = `${baseUrl}/squads/${squads}`;
@ -239,7 +229,7 @@ async function handler(ctx) {
first: limit,
},
});
const items = getList(data, innerSharedContent, true);
const items = getList(data, true);
return {
title: `${name} - daily.dev`,

View File

@ -29,6 +29,7 @@ const query = /* GraphQL */ `
sharedPost {
id
title
summary
image
readTime
permalink
@ -110,7 +111,7 @@ const query = /* GraphQL */ `
`;
export const route: Route = {
path: '/upvoted/:period?/:innerSharedContent?/:dateSort?',
path: '/upvoted/:period?/:dateSort?',
example: '/daily/upvoted/7',
view: ViewType.Articles,
radar: [
@ -119,14 +120,6 @@ export const route: Route = {
},
],
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',
@ -154,7 +147,6 @@ export const route: Route = {
async function handler(ctx) {
const link = `${baseUrl}/posts/upvoted`;
const limit = ctx.req.query('limit') ? Number(ctx.req.query('limit')) : 20;
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;
const period = ctx.req.param('period') ? Number(ctx.req.param('period')) : 7;
@ -166,7 +158,7 @@ async function handler(ctx) {
first: limit,
},
});
const items = getList(data, innerSharedContent, dateSort);
const items = getList(data, dateSort);
return {
title: 'Most upvoted posts for developers | daily.dev',

View File

@ -135,23 +135,13 @@ const userPostQuery = /* GraphQL */ `
`;
export const route: Route = {
path: '/user/:userId/:innerSharedContent?',
path: '/user/:userId',
example: '/daily/user/kramer',
radar: [
{
source: ['app.daily.dev/:userId/posts', 'app.daily.dev/:userId'],
},
],
parameters: {
innerSharedContent: {
description: 'Where to Fetch inner Shared Posts instead of original',
default: 'false',
options: [
{ value: 'false', label: 'False' },
{ value: 'true', label: 'True' },
],
},
},
name: 'User Posts',
maintainers: ['TonyRL'],
handler,
@ -161,7 +151,6 @@ export const route: Route = {
async function handler(ctx) {
const userId = ctx.req.param('userId');
const limit = ctx.req.query('limit') ? Number(ctx.req.query('limit')) : 7;
const innerSharedContent = ctx.req.param('innerSharedContent') ? JSON.parse(ctx.req.param('innerSharedContent')) : false;
const buildId = await getBuildId();
const userData = await cache.tryGet(`daily:user:${userId}`, async () => {
@ -185,7 +174,7 @@ async function handler(ctx) {
loggedIn: false,
},
});
return getList(edges, innerSharedContent, true);
return getList(edges, true);
},
config.cache.routeExpire,
false

View File

@ -46,29 +46,21 @@ const render = ({ image, content }: { image?: string; content?: string }) =>
</>
);
export const getList = (edges, innerSharedContent: boolean, dateSort: boolean) =>
export const getList = (edges, dateSort: boolean) =>
edges.map(({ node }) => {
let link: string;
let title: string;
if (innerSharedContent && node.type === 'share') {
link = node.sharedPost.permalink;
title = node.sharedPost.title;
} else {
link = node.commentsPermalink ?? node.permalink;
title = node.title;
}
const post = node.type === 'share' ? node.sharedPost : node;
return {
id: node.id,
title,
link,
title: post.title,
link: node.commentsPermalink ?? node.permalink,
guid: node.permalink,
description: render({
image: node.image,
content: node.contentHtml?.replaceAll('\n', '<br>') ?? node.summary,
image: post.image?.includes('/public/Placeholder') ? undefined : post.image,
content: node.contentHtml?.replaceAll('\n', '<br>') ?? post.summary,
}),
author: node.author?.name,
itunes_item_image: node.image,
itunes_item_image: post.image,
pubDate: dateSort ? parseDate(node.createdAt) : '',
upvotes: node.numUpvotes,
comments: node.numComments,