Skip to content

Commit

Permalink
feat(route): v1tx (DIYgod#12034)
Browse files Browse the repository at this point in the history
* feat(route): v1tx

* fix: remove author
  • Loading branch information
TonyRL authored Mar 3, 2023
1 parent 7e28a20 commit 1726af2
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/blog.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ username 为博主用户名,而非`xxx.hashnode.dev`中`xxx`所代表的 blog

<Route author="chazeon" example="/stratechery" path="/stratechery" />

## v1tx

### 最新文章

<Route author="TonyRL" example="/v1tx" path="/v1tx" radar="1" rssbud="1" />

## Whoscall

### 最新文章
Expand Down
36 changes: 36 additions & 0 deletions lib/v2/v1tx/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const baseUrl = 'https://www.v1tx.com';
const response = await got(`${baseUrl}/wp-json/wp/v2/posts`, {
searchParams: {
per_page: ctx.query.limit ?? 100,
},
});

const items = response.data.map((item) => {
const $ = cheerio.load(item.content.rendered, null, false);
$('figure > picture > source').remove();
$('img').each((_, img) => {
img.attribs.src = img.attribs.src.replace(/-1024x\d+\.jpg/, '.webp').replace('.jpg', '.webp');
delete img.attribs.srcset;
});
return {
title: item.title.rendered,
link: item.link,
guid: item.guid.rendered,
description: $.html(),
pubDate: parseDate(item.date_gmt),
};
});

ctx.state.data = {
title: 'v1tx - 发现实用工具与软件',
description: 'v1tx.com 专注于发现新应用,推荐各种效率工具、软件、APP,包括Windows、Mac、Android、iOS、网页等多平台应用,让每个人找到适合的软件并掌握使用技巧',
link: baseUrl,
image: `${baseUrl}/wp-content/uploads/2018/10/cropped-Favicon.webp`,
item: items,
};
};
4 changes: 4 additions & 0 deletions lib/v2/v1tx/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
'': ['TonyRL'],
'/': ['TonyRL'],
};
13 changes: 13 additions & 0 deletions lib/v2/v1tx/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'v1tx.com': {
_name: 'v1tx',
'.': [
{
title: '最新文章',
docs: 'https://docs.rsshub.app/blog.html#v1tx',
source: ['/'],
target: '/v1tx',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/v1tx/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/', require('./index'));
};

0 comments on commit 1726af2

Please sign in to comment.