From c4eb096cf86293dd4806082866551444133fa9cf Mon Sep 17 00:00:00 2001
From: James Shih <9959168+jameshih@users.noreply.github.com>
Date: Mon, 13 Mar 2023 17:16:56 +0800
Subject: [PATCH] fix(route): coindesk consensus magazine (#12086)
* update Coindesk Consensus Magazine route
* Update lib/v2/coindesk/index.js
* Update lib/v2/coindesk/index.js
---------
Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com>
---
lib/v2/coindesk/index.js | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/lib/v2/coindesk/index.js b/lib/v2/coindesk/index.js
index d9b2dacb1..5d44cbd71 100644
--- a/lib/v2/coindesk/index.js
+++ b/lib/v2/coindesk/index.js
@@ -5,9 +5,8 @@ const rootUrl = 'https://www.coindesk.com';
module.exports = async (ctx) => {
const channel = ctx.params.channel ?? 'consensus-magazine';
- const response = await got.get(`${rootUrl}/${channel}`);
+ const response = await got.get(`${rootUrl}/${channel}/`);
const $ = cheerio.load(response.data);
- const title = $('div.title-holder h2').text();
const content = JSON.parse(
$('#fusion-metadata')
.text()
@@ -16,16 +15,15 @@ module.exports = async (ctx) => {
const o1 = content['websked-collections'];
// Object key names are different every week
- const feature = o1[Object.keys(o1)[2]];
- const opinion = o1[Object.keys(o1)[3]];
+ const articles = o1[Object.keys(o1)[2]];
- const list = [...feature.data, ...opinion.data];
+ const list = articles.data;
const items = list.map((item) => ({
title: item.headlines.basic,
link: rootUrl + item.canonical_url,
- description: title + '
' + item.subheadlines.basic,
- pubDate: item.publish_date,
+ description: item.subheadlines.basic,
+ pubDate: item.display_date,
}));
ctx.state.data = {