From 2c5929347a8283005df2a7b771f40ee324c38cfe Mon Sep 17 00:00:00 2001 From: Tony Date: Wed, 22 Jul 2026 04:43:03 +0800 Subject: [PATCH] fix(route/daily): remove innerSharedContent parameter (#22786) --- lib/routes/daily/discussed.ts | 20 +++++++++----------- lib/routes/daily/popular.ts | 14 +++----------- lib/routes/daily/source.ts | 14 +++----------- lib/routes/daily/squads.ts | 16 +++------------- lib/routes/daily/upvoted.ts | 14 +++----------- lib/routes/daily/user.ts | 15 ++------------- lib/routes/daily/utils.tsx | 22 +++++++--------------- 7 files changed, 30 insertions(+), 85 deletions(-) diff --git a/lib/routes/daily/discussed.ts b/lib/routes/daily/discussed.ts index 6b012d0c8..1baec6df5 100644 --- a/lib/routes/daily/discussed.ts +++ b/lib/routes/daily/discussed.ts @@ -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', diff --git a/lib/routes/daily/popular.ts b/lib/routes/daily/popular.ts index 8b48490be..d4331342a 100644 --- a/lib/routes/daily/popular.ts +++ b/lib/routes/daily/popular.ts @@ -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', diff --git a/lib/routes/daily/source.ts b/lib/routes/daily/source.ts index 104b5fdeb..3f06cbb2e 100644 --- a/lib/routes/daily/source.ts +++ b/lib/routes/daily/source.ts @@ -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 diff --git a/lib/routes/daily/squads.ts b/lib/routes/daily/squads.ts index c71880192..783316d90 100644 --- a/lib/routes/daily/squads.ts +++ b/lib/routes/daily/squads.ts @@ -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`, diff --git a/lib/routes/daily/upvoted.ts b/lib/routes/daily/upvoted.ts index 43f9f2723..5f17c2f34 100644 --- a/lib/routes/daily/upvoted.ts +++ b/lib/routes/daily/upvoted.ts @@ -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', diff --git a/lib/routes/daily/user.ts b/lib/routes/daily/user.ts index d3eda7ba1..8e7eca68e 100644 --- a/lib/routes/daily/user.ts +++ b/lib/routes/daily/user.ts @@ -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 diff --git a/lib/routes/daily/utils.tsx b/lib/routes/daily/utils.tsx index fb1fbfcf8..bcc8bf971 100644 --- a/lib/routes/daily/utils.tsx +++ b/lib/routes/daily/utils.tsx @@ -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', '
') ?? node.summary, + image: post.image?.includes('/public/Placeholder') ? undefined : post.image, + content: node.contentHtml?.replaceAll('\n', '
') ?? 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,