diff --git a/docs/blog.md b/docs/blog.md index fe48ffddcae5f6..4dbb36f5be9b65 100644 --- a/docs/blog.md +++ b/docs/blog.md @@ -148,6 +148,12 @@ username 为博主用户名,而非`xxx.hashnode.dev`中`xxx`所代表的 blog +## v1tx + +### 最新文章 + + + ## Whoscall ### 最新文章 diff --git a/lib/v2/v1tx/index.js b/lib/v2/v1tx/index.js new file mode 100644 index 00000000000000..dc15112f0c4a32 --- /dev/null +++ b/lib/v2/v1tx/index.js @@ -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, + }; +}; diff --git a/lib/v2/v1tx/maintainer.js b/lib/v2/v1tx/maintainer.js new file mode 100644 index 00000000000000..13972819d7b162 --- /dev/null +++ b/lib/v2/v1tx/maintainer.js @@ -0,0 +1,4 @@ +module.exports = { + '': ['TonyRL'], + '/': ['TonyRL'], +}; diff --git a/lib/v2/v1tx/radar.js b/lib/v2/v1tx/radar.js new file mode 100644 index 00000000000000..e36c8132138ed4 --- /dev/null +++ b/lib/v2/v1tx/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'v1tx.com': { + _name: 'v1tx', + '.': [ + { + title: '最新文章', + docs: 'https://docs.rsshub.app/blog.html#v1tx', + source: ['/'], + target: '/v1tx', + }, + ], + }, +}; diff --git a/lib/v2/v1tx/router.js b/lib/v2/v1tx/router.js new file mode 100644 index 00000000000000..7e427447c70050 --- /dev/null +++ b/lib/v2/v1tx/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/', require('./index')); +};