mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-01 14:57:14 +08:00
docs(core): pubdate, npm ci with templates (#7501)
This commit is contained in:
@@ -54,6 +54,10 @@ Reference: https://docs.rsshub.app/en/joinus/
|
||||
- [缓存说明](https://docs.rsshub.app/joinus/#ti-jiao-xin-de-rsshub-gui-ze-bian-xie-jiao-ben-shi-yong-huan-cun) | [How to use cache](https://docs.rsshub.app/joinus/#ti-jiao-xin-de-rsshub-gui-ze-bian-xie-jiao-ben-shi-yong-huan-cun)
|
||||
- [ ] 目标是否有明显的反爬/频率限制? Is there any sign of anti-bot or rate limit?
|
||||
- [ ] 如果有, 是否有对应的措施? (延长缓存时间, 写文档说明, etc.) If yes, do your code reflect this sign? (e.g. write documentations, use long cache time)
|
||||
- [ ] 目标是否有提供日期? Is there a date in the source?
|
||||
- [ ] 如果有,包是否正确解析? If there is, can this script provide this info?
|
||||
- [ ] 如果有提供解析能力,时区是否正确调整? Is the timezone correctly provided?
|
||||
- 如果有提供日期,但是没有提供解析,请说明原因 If there is a date but this script does not parse, please provide your reason.
|
||||
- [ ] 是否引入的新的包? Any new package introduced?
|
||||
- 如果有, 请说明原因. If yes, please state your reason
|
||||
- [ ] 是否使用了`Puppeteer`? Make use of `Puppeteer`?
|
||||
|
||||
@@ -2,7 +2,6 @@ node_modules
|
||||
npm-debug.log
|
||||
error.log
|
||||
combined.log
|
||||
package-lock.json
|
||||
.vscode
|
||||
.idea
|
||||
.DS_Store
|
||||
|
||||
+18
-5
@@ -24,11 +24,24 @@ const loopSideBar = (children, type, lang, prefix) =>
|
||||
lang,
|
||||
}));
|
||||
const loopNav = (nav, lang) =>
|
||||
nav.map((e) => ({
|
||||
path: path.resolve(__dirname, '..', e.link.slice(1), 'README.md'),
|
||||
type: file.NAV_TYPE,
|
||||
lang,
|
||||
}));
|
||||
nav.map((e) => {
|
||||
if (e.items) {
|
||||
return loopNav(e.items, lang);
|
||||
}
|
||||
if (e.link.endsWith('/')) {
|
||||
return {
|
||||
path: path.resolve(__dirname, '..', e.link.slice(1), 'README.md'),
|
||||
type: file.NAV_TYPE,
|
||||
lang,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
path: path.resolve(__dirname, '..', `${e.link}.md`),
|
||||
type: file.NAV_TYPE,
|
||||
lang,
|
||||
};
|
||||
}
|
||||
});
|
||||
const loopType = (sidebar, lang, prefix) => loopSideBar(sidebar[0].children, file.GUIDE_TYPE, lang, prefix).concat(loopSideBar(sidebar[1].children, file.ROUTE_TYPE, lang, prefix));
|
||||
|
||||
/**
|
||||
|
||||
@@ -86,24 +86,7 @@ module.exports = {
|
||||
label: '简体中文',
|
||||
editLinkText: '在 GitHub 上编辑此页',
|
||||
lastUpdated: '上次更新',
|
||||
nav: [
|
||||
{
|
||||
text: '指南',
|
||||
link: '/',
|
||||
},
|
||||
{
|
||||
text: '参与我们',
|
||||
link: '/joinus/',
|
||||
},
|
||||
{
|
||||
text: '部署',
|
||||
link: '/install/',
|
||||
},
|
||||
{
|
||||
text: '支持 RSSHub',
|
||||
link: '/support/',
|
||||
},
|
||||
],
|
||||
nav: require('./nav/zh'),
|
||||
sidebar: {
|
||||
'/': [
|
||||
{
|
||||
@@ -150,24 +133,7 @@ module.exports = {
|
||||
label: 'English',
|
||||
editLinkText: 'Edit this page on GitHub',
|
||||
lastUpdated: 'Last Updated',
|
||||
nav: [
|
||||
{
|
||||
text: 'Guide',
|
||||
link: '/en/',
|
||||
},
|
||||
{
|
||||
text: 'Join us',
|
||||
link: '/en/joinus/',
|
||||
},
|
||||
{
|
||||
text: 'Deploy',
|
||||
link: '/en/install/',
|
||||
},
|
||||
{
|
||||
text: 'Support RSSHub',
|
||||
link: '/en/support/',
|
||||
},
|
||||
],
|
||||
nav: require('./nav/en'),
|
||||
sidebar: {
|
||||
'/en/': [
|
||||
{
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
module.exports = [
|
||||
{
|
||||
text: 'Guide',
|
||||
link: '/en/',
|
||||
},
|
||||
{
|
||||
text: 'Join Us',
|
||||
ariaLabel: 'Join Us',
|
||||
items: [
|
||||
{
|
||||
text: 'Getting Started',
|
||||
link: '/joinus/quick-start',
|
||||
},
|
||||
{
|
||||
text: 'More details',
|
||||
items: [
|
||||
{
|
||||
text: 'Date Handling',
|
||||
link: '/joinus/pub-date',
|
||||
},
|
||||
{
|
||||
text: 'Use Cache',
|
||||
link: '/joinus/use-cache',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Deploy',
|
||||
link: '/en/install/',
|
||||
},
|
||||
{
|
||||
text: 'Support RSSHub',
|
||||
link: '/en/support/',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,37 @@
|
||||
module.exports = [
|
||||
{
|
||||
text: '指南',
|
||||
link: '/',
|
||||
},
|
||||
{
|
||||
text: '参与我们',
|
||||
ariaLabel: '参与我们',
|
||||
items: [
|
||||
{
|
||||
text: '快速开始',
|
||||
link: '/joinus/quick-start',
|
||||
},
|
||||
{
|
||||
text: '详细规范',
|
||||
items: [
|
||||
{
|
||||
text: '日期处理',
|
||||
link: '/joinus/pub-date',
|
||||
},
|
||||
{
|
||||
text: '使用缓存',
|
||||
link: '/joinus/use-cache',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
text: '部署',
|
||||
link: '/install/',
|
||||
},
|
||||
{
|
||||
text: '支持 RSSHub',
|
||||
link: '/support/',
|
||||
},
|
||||
];
|
||||
@@ -157,10 +157,10 @@ Execute the following commands to install dependencies
|
||||
Using `npm`
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
$ npm ci
|
||||
```
|
||||
|
||||
Or `yarn`
|
||||
Or `yarnv1` (not recommended)
|
||||
|
||||
```bash
|
||||
$ yarn
|
||||
|
||||
@@ -159,10 +159,10 @@ $ cd RSSHub
|
||||
使用 `npm`
|
||||
|
||||
```bash
|
||||
$ npm install --production
|
||||
$ npm ci --production
|
||||
```
|
||||
|
||||
或 `yarn`
|
||||
或 `yarnv1` (不推荐)
|
||||
|
||||
```bash
|
||||
$ yarn install --production
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# 日期处理
|
||||
|
||||
在抓取网页的时候,通常情况下网页会提供日期。这篇教程用于说明插件应当如何正确的处理相关情况
|
||||
|
||||
## 没有日期
|
||||
|
||||
在源没有提供日期的时候,**请勿添加日期**。`pubDate`选项应当被留空。
|
||||
|
||||
## 规范
|
||||
|
||||
`pubDate`接受一个[Date Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)。或者是可以被正确解析的字符串。这里**并不推荐直接返回字符串的方式**,因为其行为可能在不同环境下不一致,[Date.parse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse)
|
||||
|
||||
## 使用工具类
|
||||
|
||||
目前,我们推荐使用[dayjs](https://github.com/iamkun/dayjs)进行日期的处理和时区调整。相关工具类有两个:
|
||||
|
||||
### Parse Date
|
||||
|
||||
这个是一个工具类用于使用[dayjs](https://github.com/iamkun/dayjs)。大部分情况下,应当可以直接使用他获取到正确的`Date Object`
|
||||
|
||||
具体解析参数请参考dayjs github说明
|
||||
|
||||
```javascript
|
||||
const parseDate = require('@/utils/parse-date');
|
||||
|
||||
const pubDate = parseDate('2020/12/30', 'YYYY/MM/DD')
|
||||
```
|
||||
|
||||
|
||||
### Timezone
|
||||
|
||||
部分网站并不会依据访问者来源进行时区转换,此时获取到的时间是网站本地时间,不一定适合所有RSS订阅者。此时,应当手动指定获取的时间时区:
|
||||
|
||||
::: warning 注意
|
||||
此时,时间将会被转换到服务器时间,方便后续中间件处理。这个是正常流程!
|
||||
:::
|
||||
|
||||
```javascript
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
const pubDate = timezone(new Date(), +8)
|
||||
```
|
||||
@@ -0,0 +1,5 @@
|
||||
# 使用缓存
|
||||
|
||||
部分RSS在生成时需要访问数个页面,这些页面同时并不是很可能经常变化。出于减轻对方服务器压力和节约不必要流量/算力的考虑,这种情况下应当使用缓存。下面是关于缓存工具类的使用场景和具体介绍
|
||||
|
||||
<!-- @TODO 在cache类重构后完善 -->
|
||||
Generated
+20423
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -59,7 +59,7 @@
|
||||
"remark-pangu": "2.2.0",
|
||||
"remark-preset-prettier": "0.4.1",
|
||||
"staged-git-files": "1.2.0",
|
||||
"string-width": "5.0.0",
|
||||
"string-width": "4.2.2",
|
||||
"supertest": "6.1.3",
|
||||
"vuepress": "1.8.2",
|
||||
"yorkie": "2.0.0"
|
||||
|
||||
Reference in New Issue
Block a user