Skip to content

Commit

Permalink
fix: outdated route DoNews (DIYgod#6522)
Browse files Browse the repository at this point in the history
  • Loading branch information
laampui authored Dec 26, 2020
1 parent c72f9d4 commit 50d3126
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
6 changes: 3 additions & 3 deletions docs/new-media.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ pageClass: routes

<Route author="HenryQW" example="/donews" path="/donews/:column?" :paramsDesc="['栏目代码, 默认为首页.']">

| 首页 | 商业 | 创业 | 互娱 | 科技 | 专栏 |
| ---- | ------- | -------- | ---- | ---------- | ------- |
| (空) | company | business | ent | technology | idonews |
| 首页 | 商业 | 创业 | 互娱 | 科技 | 专栏 |
| ---- | ------- | -------- | ---- | ------- | ------- |
| (空) | company | business | ent | digital | idonews |

</Route>

Expand Down
3 changes: 1 addition & 2 deletions lib/routes/donews/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ module.exports = async (ctx) => {
switch (column) {
case '':
// 首页轮播
list = $('.focues.hide > ul > li > a').get();
list = list.concat($('.fl.w840 > .block > dl > dd > h3 > a').slice(0, 7).get());
list = $('a.news-item').get();

break;
case 'ent':
Expand Down
10 changes: 3 additions & 7 deletions lib/routes/donews/utils.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
const cheerio = require('cheerio');
const got = require('@/utils/got');
const date = require('@/utils/date');

const ProcessFeed = async (link) => {
const response = await got.get(link);

const $ = cheerio.load(response.data);

const meta = $($('#main .fl')[0]);

return {
title: $('h1').text() || $($('h2')[1]).text(),
author: meta.find('span:nth-child(1)').text(),
title: $('.detail-con h1').text() || $('.detail-con h2').text().replace('{{news.title}}', ''),
author: $('.tag > .fl > span:nth-child(2)').text().replace('{{news.author}}', ''),
description: $('.article-con').html(),
pubDate: date(meta.find('span:nth-child(2)').text(), 8),
pubDate: new Date($('.tag > .fl > span:nth-child(1)').text().replace('{{news.timeFormat}}', '')),
link,
};
};
Expand Down

0 comments on commit 50d3126

Please sign in to comment.