Files
RSSHub/routes/twitter/user.js
T
さくら 49de384d2e feat: add prettier and commit hooks (#144)
* feat: add prettier and commit hooks

* style(*): prettier format

* fix(eslint): parsing error: Unexpected token ...

* style(eslint): eslint --fix

* style(bilibili): fix `no-undef` and `no-unused-vars`

* style(jiandan): fix eqeqeq

* style(pixiv): disable `no-constant-condition` rule for eslint

* fix(pixiv): use template string

* style(toutiao): remove unused variables

* style(weibo): use `forEach` instead of `map`

The array has no return value, you should use `forEach` instead of `map`

* chore(hooks): add eslint hooks

* chore(hooks): switch from husky to yorkie

* style(zhihu): prettier format

* style(docs): fix vuepress custom container

https://vuepress.vuejs.org/guide/markdown.html#custom-containers

* chore(prettier): set a more reasonable `printWidth` value

* style(*): better prettier format
2018-05-17 10:52:29 +08:00

27 lines
874 B
JavaScript

const Twit = require('twit');
const config = require('../../config');
const T = new Twit(config.twitter);
module.exports = async (ctx) => {
const id = ctx.params.id;
const result = await T.get('statuses/user_timeline', {
screen_name: id,
});
const data = result.data;
ctx.state.data = {
title: `${data[0].user.name} 的 Twitter`,
link: `https://twitter.com/${id}/`,
description: data[0].user.description,
item: data.map((item) => ({
title: `${item.in_reply_to_screen_name ? 'Re ' : ''}${item.text.length > 30 ? item.text.slice(0, 30) + '...' : item.text}`,
description: `${item.in_reply_to_screen_name ? 'Re ' : ''}${item.text}`,
pubDate: new Date(item.createdTime).toUTCString(),
link: `https://twitter.com/${id}/status/${item.id_str}`,
})),
};
};