mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-28 13:39:28 +07:00
🐛 fix: 修正返回结果导致插件无法正常识别的问题
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { PluginRunner } from '@/plugins/type';
|
||||
|
||||
import { Result } from './type';
|
||||
import { ParserResponse, Result } from './type';
|
||||
|
||||
const BASE_URL = process.env.BROWSERLESS_URL ?? 'https://chrome.browserless.io';
|
||||
const BROWSERLESS_TOKEN = process.env.BROWSERLESS_TOKEN;
|
||||
@@ -34,10 +34,12 @@ const runner: PluginRunner<{ url: string }, Result> = async ({ url }) => {
|
||||
method: 'POST',
|
||||
});
|
||||
|
||||
return await parseRes.json();
|
||||
const { title, textContent, siteName } = (await parseRes.json()) as ParserResponse;
|
||||
|
||||
return { content: textContent, title, url, website: siteName };
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return { content: '抓取失败', errorMessage: (error as any).message };
|
||||
return { content: '抓取失败', errorMessage: (error as any).message, url };
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,35 @@
|
||||
export type Result = {
|
||||
content?: string;
|
||||
content: string;
|
||||
title?: string;
|
||||
url?: string;
|
||||
url: string;
|
||||
website?: string;
|
||||
};
|
||||
|
||||
export interface ParserResponse {
|
||||
/** author metadata */
|
||||
byline: string;
|
||||
|
||||
/** HTML string of processed article content */
|
||||
content: string;
|
||||
|
||||
/** content direction */
|
||||
dir: string;
|
||||
|
||||
/** article description, or short excerpt from the content */
|
||||
excerpt: string;
|
||||
|
||||
/** content language */
|
||||
lang: string;
|
||||
|
||||
/** length of an article, in characters */
|
||||
length: number;
|
||||
|
||||
/** name of the site */
|
||||
siteName: string;
|
||||
|
||||
/** text content of the article, with all the HTML tags removed */
|
||||
textContent: string;
|
||||
|
||||
/** article title */
|
||||
title: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user