chore: commit docs to docs repo

This commit is contained in:
DIYgod
2024-03-18 19:36:56 +08:00
parent 4a1c89cf0d
commit 939a77ecab
12 changed files with 213 additions and 45 deletions
+23
View File
@@ -1,6 +1,7 @@
name: Build assets
on:
workflow_dispatch:
push:
branches:
- master
@@ -46,3 +47,25 @@ jobs:
publish_dir: ./assets
user_name: 'github-actions[bot]'
user_email: '41898282+github-actions[bot]@users.noreply.github.com'
- name: Pushes to docs repository - en
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets.DOCS_SSH_DEPLOY_KEY }}
with:
source-directory: './assets/build/docs/en'
target-directory: './src/routes'
destination-github-username: 'RSSNext'
destination-repository-name: 'rsshub-docs'
user-email: '41898282+github-actions[bot]@users.noreply.github.com'
target-branch: 'github-actions[bot]'
- name: Pushes to docs repository - zh
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets.DOCS_SSH_DEPLOY_KEY }}
with:
source-directory: './assets/build/docs/zh'
target-directory: './src/zh/routes'
destination-github-username: 'RSSNext'
destination-repository-name: 'rsshub-docs'
user-email: '41898282+github-actions[bot]@users.noreply.github.com'
target-branch: 'github-actions[bot]'
+1 -1
View File
@@ -30,7 +30,7 @@ export const route: Route = {
maintainers: ['EthanWng97'],
handler,
url: 'offer.1point3acres.com/',
description: `:::tip[三个 id 获取方式]
description: `:::tip 三个 id 获取方式
1. 打开 [https://offer.1point3acres.com](https://offer.1point3acres.com)
2. 打开控制台
3. 切换到 Network 面板
+1 -1
View File
@@ -99,7 +99,7 @@ export const route: Route = {
用例:\`/bilibili/user/dynamic/2267573/showEmoji=1&disableEmbed=1&useAvid=1\`
:::tip[动态的专栏显示全文]
:::tip 动态的专栏显示全文
动态的专栏显示全文请使用通用参数里的 \`mode=fulltext\`
举例: bilibili 专栏全文输出 /bilibili/user/dynamic/2267573/?mode=fulltext
+1 -1
View File
@@ -26,7 +26,7 @@ export const route: Route = {
name: 'UP 主投稿',
maintainers: ['DIYgod'],
handler,
description: `:::tip[动态的专栏显示全文]
description: `:::tip 动态的专栏显示全文
可以使用 [UP 主动态](#bilibili-up-zhu-dong-tai)路由作为代替绕过反爬限制
:::`,
};
+1 -1
View File
@@ -33,7 +33,7 @@ export const route: Route = {
| ------------ |
| dna-verified |
:::tip[Topic]
:::tip Topic
The URL of the form \`https://www.dnaindia.com/topic/dna-verified\` demonstrates the utilization of the subdomain \`topic\`
:::`,
description: `Categories:
+1 -1
View File
@@ -23,7 +23,7 @@ export const route: Route = {
name: 'Category',
maintainers: ['Rjnishant530'],
handler,
description: `:::note[Category]
description: `:::note Category
| Category | Link |
| --------------------- | ------------------ |
| **Business** | business |
+1 -1
View File
@@ -7,7 +7,7 @@ export const namespace: Namespace = {
Requests from non-Asia areas will be redirected to login page.
:::
:::tip[Language]
:::tip Language
You can change the language of each route to the languages listed below.
| English | 日本语 | 한국의 | 中文 |
+1 -1
View File
@@ -7,7 +7,7 @@ export const namespace: Namespace = {
Need to set up Notion integration, please refer to [Route-specific Configurations](https://docs.rsshub.app/install/#Deployment) for details.
:::
:::tip[Recommendation]
:::tip Recommendation
It is recommended to use with clipping tools such as Notion Web Clipper.
:::`,
};
+1 -1
View File
@@ -26,7 +26,7 @@ export const route: Route = {
name: 'User Profile',
maintainers: ['MisteryMonster'],
handler,
description: `:::tip[Special category name attention]
description: `:::tip Special category name attention
Some of the categories contain slash like \`3D/CG\` , must change the slash \`/\` to the vertical bar\`|\`.
:::`,
};
+1 -1
View File
@@ -21,7 +21,7 @@ export const route: Route = {
name: '论坛',
maintainers: ['akynazh'],
handler,
description: `:::tip[关于子论坛 id 的获取方法]
description: `:::tip 关于子论坛 id 的获取方法
\`/xsijishe/forum/51\` 对应于论坛 \`https://xsijishe.com/forum-51-1.html\`,这个论坛的 fid 为 51,也就是 \`forum-{fid}-1\` 中的 fid。
:::`,
};
+41 -36
View File
@@ -4,6 +4,7 @@ import { parse } from 'tldts';
import fs from 'node:fs';
import * as path from 'node:path';
import toSource from 'tosource';
import { categories } from './data';
const maintainers: Record<string, string[]> = {};
const radar: {
@@ -61,6 +62,7 @@ for (const namespace in namespaces) {
};
}
docs[category][namespace].name = namespaces[namespace].name;
docs[category][namespace].url = namespaces[namespace].url;
docs[category][namespace].description = namespaces[namespace].description;
docs[category][namespace].routes[realPath] = data;
}
@@ -72,35 +74,19 @@ fs.writeFileSync(path.join(__dirname, '../../assets/build/radar-rules.js'), `(${
fs.writeFileSync(path.join(__dirname, '../../assets/build/maintainers.json'), JSON.stringify(maintainers, null, 2));
fs.writeFileSync(path.join(__dirname, '../../assets/build/routes.json'), JSON.stringify(namespaces, null, 2));
// Generate markdown
const pinyinCompare = new Intl.Collator('zh-Hans-CN-u-co-pinyin').compare;
const isASCII = (str) => /^[\u0000-\u007F]*$/.test(str);
const md = {};
for (const category in docs) {
md[category] = `# ${category}\n\n`;
function generateMd(lang) {
const md = {};
for (const category in docs) {
const nameObj = categories.find((c) => c.link.includes(category));
md[category] = `# ${`${nameObj!.icon} ${nameObj![lang]}`}\n\n`;
const namespaces = Object.keys(docs[category]).sort((a, b) => {
const aname = docs[category][a].name[0];
const bname = docs[category][b].name[0];
const ia = isASCII(aname);
const ib = isASCII(bname);
if (ia && ib) {
return aname.toLowerCase() < bname.toLowerCase() ? -1 : 1;
} else if (ia || ib) {
return ia > ib ? -1 : 1;
} else {
return pinyinCompare(aname, bname);
}
});
for (const namespace of namespaces) {
md[category] += `## ${docs[category][namespace].name}\n\n`;
if (docs[category][namespace].description) {
md[category] += `${docs[category][namespace].description}\n\n`;
}
const realPaths = Object.keys(docs[category][namespace].routes).sort((a, b) => {
const aname = docs[category][namespace].routes[a].name[0];
const bname = docs[category][namespace].routes[b].name[0];
const namespaces = Object.keys(docs[category]).sort((a, b) => {
const aname = docs[category][a].name[0];
const bname = docs[category][b].name[0];
const ia = isASCII(aname);
const ib = isASCII(bname);
if (ia && ib) {
@@ -111,21 +97,40 @@ for (const category in docs) {
return pinyinCompare(aname, bname);
}
});
for (const namespace of namespaces) {
md[category] += `## ${docs[category][namespace].name} ${docs[category][namespace].url ? `<Site url="${docs[category][namespace].url}"/>` : ''}\n\n`;
if (docs[category][namespace].description) {
md[category] += `${docs[category][namespace].description}\n\n`;
}
for (const realPath of realPaths) {
const data = docs[category][namespace].routes[realPath];
md[category] += `### ${data.name}\n\n`;
md[category] += `<Route namespace="${namespace}" data={${JSON.stringify(data)}} />\n\n`;
if (data.description) {
md[category] += `${data.description}\n\n`;
const realPaths = Object.keys(docs[category][namespace].routes).sort((a, b) => {
const aname = docs[category][namespace].routes[a].name[0];
const bname = docs[category][namespace].routes[b].name[0];
const ia = isASCII(aname);
const ib = isASCII(bname);
if (ia && ib) {
return aname.toLowerCase() < bname.toLowerCase() ? -1 : 1;
} else if (ia || ib) {
return ia > ib ? -1 : 1;
} else {
return pinyinCompare(aname, bname);
}
});
for (const realPath of realPaths) {
const data = docs[category][namespace].routes[realPath];
md[category] += `### ${data.name} ${data.url || docs[category][namespace].url ? `<Site url="${data.url || docs[category][namespace].url}" size="sm" />` : ''}\n\n`;
md[category] += `<Route namespace="${namespace}" :data='${JSON.stringify(data).replaceAll(`'`, '&#39;')}' />\n\n`;
if (data.description) {
md[category] += `${data.description}\n\n`;
}
}
}
}
}
fs.writeFileSync(path.join(__dirname, '../../assets/build/docs.json'), JSON.stringify(docs, null, 2));
if (fs.existsSync(path.join(__dirname, '../../website'))) {
fs.mkdirSync(path.join(__dirname, `../../assets/build/docs/${lang}`), { recursive: true });
for (const category in md) {
fs.writeFileSync(path.join(__dirname, `../../website/docs/routes/${category}.mdx`), md[category]);
fs.writeFileSync(path.join(__dirname, `../../assets/build/docs/${lang}/${category}.md`), md[category]);
}
}
generateMd('en');
generateMd('zh');
+140
View File
@@ -0,0 +1,140 @@
export const categories = [
{
icon: '💬',
link: '/routes/social-media',
en: 'Social Media',
zh: '社交媒体',
},
{
icon: '📱',
link: '/routes/new-media',
en: 'New media',
zh: '新媒体',
},
{
icon: '📰',
link: '/routes/traditional-media',
en: 'Traditional media',
zh: '传统媒体',
},
{
icon: '💬️',
link: '/routes/bbs',
en: 'BBS',
zh: '论坛',
},
{
icon: '🖊️',
link: '/routes/blog',
en: 'Blog',
zh: '博客',
},
{
icon: '💻',
link: '/routes/programming',
en: 'Programming',
zh: '编程',
},
{
icon: '🎨️',
link: '/routes/design',
en: 'Design',
zh: '设计',
},
{
icon: '🎥',
link: '/routes/live',
en: 'Live',
zh: '直播',
},
{
icon: '🔊',
link: '/routes/multimedia',
en: 'Multimedia',
zh: '音视频',
},
{
icon: '🖼️',
link: '/routes/picture',
en: 'Picture',
zh: '图片',
},
{
icon: '🎨️',
link: '/routes/anime',
en: 'ACG',
zh: '二次元',
},
{
icon: '🔄',
link: '/routes/program-update',
en: 'Application Updates',
zh: '程序更新',
},
{
icon: '🎓',
link: '/routes/university',
en: 'University',
zh: '大学通知',
},
{
icon: '❗️',
link: '/routes/forecast',
en: 'Forecast and Alerts',
zh: '预报预警',
},
{
icon: '🛫',
link: '/routes/travel',
en: 'Travel',
zh: '出行旅游',
},
{
icon: '🛍️',
link: '/routes/shopping',
en: 'Shopping',
zh: '购物',
},
{
icon: '🎮',
link: '/routes/game',
en: 'Gaming',
zh: '游戏',
},
{
icon: '📚',
link: '/routes/reading',
en: 'Reading',
zh: '阅读',
},
{
icon: '📢',
link: '/routes/government',
en: 'Government',
zh: '政务消息',
},
{
icon: '📖',
link: '/routes/study',
en: 'Study',
zh: '学习',
},
{
icon: '🔬',
link: '/routes/journal',
en: 'Scientific Journal',
zh: '科学期刊',
},
{
icon: '💰',
link: '/routes/finance',
en: 'Finance',
zh: '金融',
},
{
icon: '🔍',
link: '/routes/other',
en: 'Uncategorized',
zh: '其他',
},
];