feat: queshu title add book name (#2862)

This commit is contained in:
Cloud
2019-08-15 22:19:00 +08:00
committed by DIYgod
parent 228313fc3e
commit d6fccdeeac
5 changed files with 15 additions and 11 deletions
-10
View File
@@ -823,16 +823,6 @@ type 为 all 时,category 参数不支持 cost 和 free
</Route>
## 缺书网
### 促销
<Route author="kt286" example="/queshu/sale" path="/queshu/sale"/>
### 单品活动信息
<Route author="kt286" example="/queshu/book/34626813" path="/queshu/book/:bookid" :paramsDesc="['图书ID,可在链接中获取']"/>
## 人人都是产品经理
### 热门文章
+10
View File
@@ -48,6 +48,16 @@ pageClass: routes
<Route author="sanmmm" example="/liwushuo/index" path="/liwushuo/index"/>
## 缺书网
### 促销
<Route author="kt286" example="/queshu/sale" path="/queshu/sale"/>
### 单品活动信息
<Route author="kt286" example="/queshu/book/34626813" path="/queshu/book/:bookid" :paramsDesc="['图书ID,可在链接中获取']"/>
## 什么值得买
::: tip 提示
+1 -1
View File
@@ -10,7 +10,7 @@ module.exports = async (ctx) => {
title: `%title%`,
allowEmpty: true,
params: {
title: '单品活动信息 - 缺书网',
title: `$('#book_left > #h1').text().trim() + ' - 单品活动信息 - 缺书网'`,
host,
},
item: {
+1
View File
@@ -22,6 +22,7 @@ module.exports = async (ctx) => {
+ '发布时间:' + $('.news_sale_detail .sale_time_end.inline_right').text()
`,
pubDate: `date($('.news_sale_detail .sale_time_end.inline_right').text())`,
},
});
};
+3
View File
@@ -2,6 +2,8 @@ const cheerio = require('cheerio');
const got = require('@/utils/got');
// eslint-disable-next-line no-unused-vars
const { addNoReferrer } = require('@/utils/common-utils');
// eslint-disable-next-line no-unused-vars
const date = require('@/utils/date');
function transElemText($, prop) {
const regex = new RegExp(/\$\((.*)\)/g);
@@ -43,6 +45,7 @@ async function buildData(data) {
const $item = $(data.item.item);
// 这里应该是可以通过参数注入一些代码的,不过应该无伤大雅
return {
link: data.link,
title: getProp(data, 'title', $),
description: getProp(data, 'description', $),
allowEmpty: data.allowEmpty || false,