refactor(plugins): searx rewrite to jsx

and fix pageno problem
This commit is contained in:
Artemy
2024-05-13 17:59:31 +03:00
parent 3cee45b591
commit c2e6475624
7 changed files with 87 additions and 42 deletions

View File

@ -8,17 +8,25 @@ export namespace JSX {
}
export function createElement(
name: string,
props: { [id: string]: string },
// eslint-disable-next-line @typescript-eslint/no-explicit-any
name: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
props: { [id: string]: any },
...content: string[]
) {
props = props || {};
const propsstr = Object.keys(props)
.map((key) => {
const value = props[key];
if (key === 'className') return `class=${value}`;
else return `${key}=${value}`;
})
.join(' ');
return `<${name} ${propsstr}>${content.join('')}</${name}>`;
if (typeof name === 'string') {
props = props || {};
const propsstr = Object.keys(props)
.map((key) => {
const value = props[key];
if (key === 'className') return `class=${value}`;
else return `${key}=${value}`;
})
.join(' ');
return `<${name} ${propsstr}>${content.join('')}</${name}>`;
} else if (typeof name === 'function') {
return name(props, ...content);
} else {
return content.join('');
}
}

View File

@ -28,8 +28,8 @@ export class HandlerInput {
export interface HandlerOutput {
content: string;
textContent: string;
title?: string;
lang?: string;
title: string;
lang: string;
}
export interface EngineOutput {