forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new and hot post of 1point3acres (DIYgod#4369)
- Loading branch information
Evan
authored
Apr 2, 2020
1 parent
10f18de
commit d4a9fe2
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const got = require('@/utils/got'); | ||
|
||
module.exports = async (ctx) => { | ||
const category = ctx.params.category; | ||
let url; | ||
let method; | ||
let description; | ||
let { title } = 'null'; | ||
// eslint-disable-next-line eqeqeq | ||
if (title == 'null') { | ||
method = 'get'; | ||
} | ||
// eslint-disable-next-line eqeqeq | ||
category == 'new' | ||
? ((url = 'https://api.1point3acres.com/api/threads?type=new&pg=1&ps=20&includes=last_reply'), (title = '最新帖子')) | ||
: ((url = 'https://api.1point3acres.com/api/threads?type=hot&pg=1&ps=20&includes=last_reply'), (title = '最热帖子')); | ||
const responseBasic = await got({ | ||
method: method, | ||
url: url, | ||
}); | ||
const data = responseBasic.data.threads; | ||
ctx.state.data = { | ||
title: `${title} - 一亩三分地`, | ||
link: `https://www.1point3acres.com/bbs/`, | ||
description: `${title} - 一亩三分地`, | ||
item: data.map((item) => { | ||
// eslint-disable-next-line eqeqeq | ||
item.last_reply.quote == '' ? (description = item.last_reply.message_bbcode) : (description = item.last_reply.quote); | ||
return { | ||
title: `${item.subject}`, | ||
// description: item.last_reply.message_bbcode,// + `<b>楼主:</b>` + item.author, | ||
description: description, | ||
// pubDate: new Date(item.submittime + ' GMT+8').toUTCString(), | ||
link: `https://instant.1point3acres.com/thread/${item.tid}`, | ||
}; | ||
}), | ||
}; | ||
}; |