diff --git a/lib/routes/docschina/jsweekly.ts b/lib/routes/docschina/jsweekly.ts
deleted file mode 100644
index 3404bbbff..000000000
--- a/lib/routes/docschina/jsweekly.ts
+++ /dev/null
@@ -1,116 +0,0 @@
-import cache from '@/utils/cache';
-import got from '@/utils/got';
-import { load } from 'cheerio';
-import MarkdownIt from 'markdown-it';
-const md = MarkdownIt();
-
-export default async (ctx) => {
- const baseURL = 'https://docschina.org';
- const { data: res } = await got(`${baseURL}/weekly/js/docs/`);
-
- const $ = load(res);
-
- const title = $('head title').text();
- const vendorLink = $('body script')
- .toArray()
- .find((i) =>
- $(i)
- .attr('src')
- .match(/vendor/)
- ).attribs.src;
-
- const { data: vendor } = await got(`https:${vendorLink}`);
- const env = vendor.match(/default.init\({env:"(.*?)"}\)/)[1]; // docschina-live-10765e
- const dataVersion = vendor.match(/,dataVersion:"(\d{4}-\d{2}-\d{2})",/)[1]; // 2020-01-10
-
- // const seqId = Math.random().toString(16).slice(2);
- const { data: document } = await got.post('https://tcb-api.tencentcloudapi.com/web', {
- headers: {
- origin: 'https://docschina.org',
- // referer: 'https://docschina.org/',
- // 'x-sdk-version': '@cloudbase/js-sdk/1.3.3',
- // 'x-seqid': seqId,
- },
- searchParams: {
- env,
- },
- json: {
- action: 'database.queryDocument',
- collectionName: 'js_weekly_document',
- dataVersion,
- env,
- limit: 100,
- query: JSON.stringify({
- path: '/',
- }),
- queryType: 'WHERE',
- // seqId,
- },
- });
-
- const { data: sidebar } = await got.post('https://tcb-api.tencentcloudapi.com/web', {
- headers: {
- origin: 'https://docschina.org',
- },
- searchParams: {
- env,
- },
- json: {
- action: 'database.queryDocument',
- collectionName: 'js_weekly_sidebar',
- dataVersion,
- env,
- limit: 100,
- query: JSON.stringify({
- pages: {
- $in: [document.data.list[0]._id],
- },
- }),
- },
- });
-
- const list = sidebar.data.list[0].value
- .filter((i) => i.key !== 'home')
- .map((i) => ({
- title: i.title,
- link: `${baseURL}/weekly/js${i.path}`,
- key: i.key,
- }));
-
- const items = await Promise.all(
- list.map((item) =>
- cache.tryGet(item.link, async () => {
- const { data: document } = await got.post('https://tcb-api.tencentcloudapi.com/web', {
- headers: {
- origin: 'https://docschina.org',
- },
- searchParams: {
- env,
- },
- json: {
- action: 'database.queryDocument',
- collectionName: 'js_weekly_document',
- dataVersion,
- env,
- limit: 100,
- query: JSON.stringify({
- path: item.key,
- }),
- },
- });
-
- item.description = md.render(document.data.list[0].content);
-
- delete item.key;
- return item;
- })
- )
- );
-
- ctx.set('data', {
- title,
- link: `${baseURL}/weekly/js/docs/`,
- icon: 'https://docschina.org/favicon.ico',
- item: items,
- });
-};
diff --git a/lib/routes/docschina/maintainer.ts b/lib/routes/docschina/maintainer.ts
index 08e5de398..96f00dd8e 100644
--- a/lib/routes/docschina/maintainer.ts
+++ b/lib/routes/docschina/maintainer.ts
@@ -1,3 +1,3 @@
export default {
- '/jsweekly': ['daijinru'],
+ '/weekly/:category?': ['daijinru', 'hestudy'],
};
diff --git a/lib/routes/docschina/radar.ts b/lib/routes/docschina/radar.ts
index ca33da825..96fdd36b6 100644
--- a/lib/routes/docschina/radar.ts
+++ b/lib/routes/docschina/radar.ts
@@ -1,11 +1,11 @@
export default {
- docschina: {
+ 'docschina.org': {
_name: '印记中文',
'.': [
{
title: '周刊 - JavaScript',
docs: 'https://docs.rsshub.app/routes/programming#yin-ji-zhong-wen-zhou-kan',
- source: ['/weekly/js/*', '/weekly/js', '/'],
+ source: ['/news/weekly/js/*', '/news/weekly/js', '/'],
target: '/docschina/jsweekly',
},
],
diff --git a/lib/routes/docschina/router.ts b/lib/routes/docschina/router.ts
index c120fac13..ced43d0af 100644
--- a/lib/routes/docschina/router.ts
+++ b/lib/routes/docschina/router.ts
@@ -1,3 +1,3 @@
export default (router) => {
- router.get('/jsweekly', './jsweekly');
+ router.get('/weekly/:category?', './weekly');
};
diff --git a/lib/routes/docschina/weekly.ts b/lib/routes/docschina/weekly.ts
new file mode 100644
index 000000000..b81eb4273
--- /dev/null
+++ b/lib/routes/docschina/weekly.ts
@@ -0,0 +1,29 @@
+import got from '@/utils/got';
+import { load } from 'cheerio';
+
+export default async (ctx) => {
+ const { category = 'js' } = ctx.req.param();
+
+ const baseURL = 'https://docschina.org';
+ const path = `/news/weekly/${category}`;
+ const { data: res } = await got(`${baseURL}${path}`);
+
+ // @ts-ignore
+ const $ = load(res);
+
+ const title = $('head title').text();
+ const dataEl = $('#__NEXT_DATA__');
+ const dataText = dataEl.text();
+ const data = JSON.parse(dataText);
+ ctx.set('data', {
+ title,
+ link: baseURL + path,
+ item: data?.props?.pageProps?.data?.map((item) => ({
+ title: item.title,
+ description: item.description,
+ link: `${baseURL}${path}/${item.issue}`,
+ author: item.editors?.join(','),
+ itunes_item_image: item.imageUrl,
+ })),
+ });
+};
diff --git a/website/docs/routes/programming.mdx b/website/docs/routes/programming.mdx
index 6420c7e33..97cf7c56d 100644
--- a/website/docs/routes/programming.mdx
+++ b/website/docs/routes/programming.mdx
@@ -1141,4 +1141,8 @@ Stay up to date on the latest React news, tutorials, resources, and more. Delive
### 周刊 - JavaScript {#yin-ji-zhong-wen-zhou-kan-javascript}
-
+
+ | javascript | node | react |
+ | ---------- | ---- | ----- |
+ | js | node | react |
+