Skip to content

Commit

Permalink
fix(route): fix utils for xhu (DIYgod#15623)
Browse files Browse the repository at this point in the history
  • Loading branch information
JimenezLi authored May 18, 2024
1 parent ea87eb8 commit 70c4fe9
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 16 deletions.
2 changes: 2 additions & 0 deletions lib/routes/zhihu/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ async function handler(ctx) {
description = detail.description;
url = `https://www.zhihu.com/roundtable/${detail.id}`;
break;
default:
description = `ζœͺηŸ₯η±»εž‹ ${item.target.type}οΌŒθ―·η‚Ήε‡»<a href="https://github.com/DIYgod/RSSHub/issues">ι“ΎζŽ₯</a>提亀issue`;
}

return {
Expand Down
14 changes: 8 additions & 6 deletions lib/routes/zhihu/xhu/activities.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Route } from '@/types';
import got from '@/utils/got';
import auth from './auth';
import utils from '../utils';
import { processImage } from '../utils';
import { parseDate } from '@/utils/parse-date';

export const route: Route = {
Expand Down Expand Up @@ -37,7 +37,7 @@ export const route: Route = {
};

async function handler(ctx) {
const xhuCookie = await auth.getCookie(ctx);
const xhuCookie = await auth.getCookie();
const hexId = ctx.req.param('hexId');
const link = `https://www.zhihu.com/people/${hexId}`;
const url = `https://api.zhihuvvv.workers.dev/people/${hexId}/activities?before_id=0&limit=20`;
Expand All @@ -62,7 +62,7 @@ async function handler(ctx) {
let title;
let description;
let url;
const images = [];
const images: string[] = [];
let text = '';
let link = '';
let author = '';
Expand All @@ -71,13 +71,13 @@ async function handler(ctx) {
case 'answer':
title = detail.question.title;
author = detail.author.name;
description = utils.ProcessImage(detail.content);
description = processImage(detail.content);
url = `https://www.zhihu.com/question/${detail.question.id}/answer/${detail.id}`;
break;
case 'article':
title = detail.title;
author = detail.author.name;
description = utils.ProcessImage(detail.content);
description = processImage(detail.content);
url = `https://zhuanlan.zhihu.com/p/${detail.id}`;
break;
case 'pin':
Expand Down Expand Up @@ -119,7 +119,7 @@ async function handler(ctx) {
case 'question':
title = detail.title;
author = detail.author.name;
description = utils.ProcessImage(detail.detail);
description = processImage(detail.detail);
url = `https://www.zhihu.com/question/${detail.id}`;
break;
case 'collection':
Expand All @@ -146,6 +146,8 @@ async function handler(ctx) {
description = detail.description;
url = `https://www.zhihu.com/roundtable/${detail.id}`;
break;
default:
description = `ζœͺηŸ₯η±»εž‹ ${item.target.type}οΌŒθ―·η‚Ήε‡»<a href="https://github.com/DIYgod/RSSHub/issues">ι“ΎζŽ₯</a>提亀issue`;
}

return {
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/zhihu/xhu/answers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const route: Route = {
};

async function handler(ctx) {
const xhuCookie = await auth.getCookie(ctx);
const xhuCookie = await auth.getCookie();
const hexId = ctx.req.param('hexId');
const link = `https://www.zhihu.com/people/${hexId}/answers`;
const url = `https://api.zhihuvvv.workers.dev/people/${hexId}/answers?limit=20&offset=0`;
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/zhihu/xhu/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const route: Route = {
};

async function handler(ctx) {
const xhuCookie = await auth.getCookie(ctx);
const xhuCookie = await auth.getCookie();
const id = ctx.req.param('id');
const link = `https://www.zhihu.com/collection/${id}`;

Expand Down
2 changes: 1 addition & 1 deletion lib/routes/zhihu/xhu/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const route: Route = {
};

async function handler(ctx) {
const xhuCookie = await auth.getCookie(ctx);
const xhuCookie = await auth.getCookie();
const hexId = ctx.req.param('hexId');
const link = `https://www.zhihu.com/people/${hexId}/posts`;
const url = `https://api.zhihuvvv.workers.dev/people/${hexId}/articles?limit=20&offset=0`;
Expand Down
6 changes: 3 additions & 3 deletions lib/routes/zhihu/xhu/question.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Route } from '@/types';
import got from '@/utils/got';
import auth from './auth';
import utils from '../utils';
import { processImage } from '../utils';
import { parseDate } from '@/utils/parse-date';

export const route: Route = {
Expand Down Expand Up @@ -29,7 +29,7 @@ export const route: Route = {
};

async function handler(ctx) {
const xhuCookie = await auth.getCookie(ctx);
const xhuCookie = await auth.getCookie();
const {
questionId,
sortBy = 'default', // default,created,updated
Expand All @@ -54,7 +54,7 @@ async function handler(ctx) {
const link = `https://www.zhihu.com/question/${questionId}/answer/${item.id}`;
const author = item.author.name;
const title = `${author}ηš„ε›žη­”οΌš${item.excerpt}`;
const description = `${author}ηš„ε›žη­”<br/><br/>${utils.ProcessImage(item.excerpt)}`;
const description = `${author}ηš„ε›žη­”<br/><br/>${processImage(item.excerpt)}`;

return {
title,
Expand Down
8 changes: 4 additions & 4 deletions lib/routes/zhihu/xhu/topic.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Route } from '@/types';
import got from '@/utils/got';
import auth from './auth';
import utils from '../utils';
import { processImage } from '../utils';
import { parseDate } from '@/utils/parse-date';

export const route: Route = {
Expand All @@ -28,7 +28,7 @@ export const route: Route = {
};

async function handler(ctx) {
const xhuCookie = await auth.getCookie(ctx);
const xhuCookie = await auth.getCookie();
const topicId = ctx.req.param('topicId');
const link = `https://www.zhihu.com/topic/${topicId}/newest`;
const url = `https://api.zhihuvvv.workers.dev/topics/${topicId}/feeds/timeline_activity?before_id=0&limit=20`;
Expand All @@ -51,13 +51,13 @@ async function handler(ctx) {
let title = '';
let description = '';
let link = '';
let pubDate = '';
let pubDate = new Date();
let author = '';

switch (type) {
case 'answer':
title = `${item.question.title}-${item.author.name}ηš„ε›žη­”οΌš${item.excerpt}`;
description = `<strong>${item.question.title}</strong><br>${item.author.name}ηš„ε›žη­”<br/>${utils.ProcessImage(item.content)}`;
description = `<strong>${item.question.title}</strong><br>${item.author.name}ηš„ε›žη­”<br/>${processImage(item.content)}`;
link = `https://www.zhihu.com/question/${item.question.id}/answer/${item.id}`;
pubDate = parseDate(item.updated_time * 1000);
author = item.author.name;
Expand Down

0 comments on commit 70c4fe9

Please sign in to comment.