fix: PNAS parameter & default value (#4258)

This commit is contained in:
hoilc 2020-03-17 12:06:59 +08:00 committed by GitHub
parent ca3b74625c
commit 4fcbecc94d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -4,13 +4,13 @@ const got = require('@/utils/got');
module.exports = async (ctx) => {
const baseUrl = `https://www.pnas.org`;
const tid = ctx.params.tid;
const topic = ctx.params.topic;
let url = `${baseUrl}/content/early/recent`;
if (tid !== 'latest') {
url = `${baseUrl}/content/by/section/${ctx.params.tid}`;
if (topic && topic !== 'latest') {
url = `${baseUrl}/content/by/section/${ctx.params.topic}`;
} else {
ctx.params.tid = 'Latest Research';
ctx.params.topic = 'Latest Research';
}
const res = await got.get(url);
@ -59,7 +59,7 @@ module.exports = async (ctx) => {
})
);
ctx.state.data = {
title: `PNAS | ${ctx.params.tid}`,
title: `PNAS | ${ctx.params.topic}`,
link: url,
item: out,
};