From 91cbc415bfa5e27d42a68d80f3cdb13a0b760671 Mon Sep 17 00:00:00 2001 From: Artemy Date: Tue, 14 May 2024 11:05:21 +0300 Subject: [PATCH] fix(sdk): jsx content join and fix searx search title --- packages/plugins/src/components/searchers.tsx | 8 +--- packages/plugins/src/engines/searx.tsx | 4 +- .../src/engines/stackoverflow/questions.tsx | 39 +++++++++---------- packages/plugins/tsconfig.json | 6 +-- packages/sdk/src/jsx.ts | 18 ++++----- packages/sdk/tsconfig.json | 6 +-- packages/server/tsconfig.json | 6 +-- 7 files changed, 39 insertions(+), 48 deletions(-) diff --git a/packages/plugins/src/components/searchers.tsx b/packages/plugins/src/components/searchers.tsx index 32213d1..6da4d41 100644 --- a/packages/plugins/src/components/searchers.tsx +++ b/packages/plugins/src/components/searchers.tsx @@ -11,13 +11,7 @@ export function PageFooter({ }) { return ( <> - {page !== 1 ? ( - <> - Previous | - - ) : ( - <> - )} + {page !== 1 ? Previous : <>}| {page} | Next ); diff --git a/packages/plugins/src/engines/searx.tsx b/packages/plugins/src/engines/searx.tsx index 6b195df..54cd063 100644 --- a/packages/plugins/src/engines/searx.tsx +++ b/packages/plugins/src/engines/searx.tsx @@ -49,7 +49,7 @@ async function search( const content = ( <> - {articles_parsed.map((a) => a.html).join('')} + {articles_parsed.map((a) => a.html)} ); @@ -59,7 +59,7 @@ async function search( return { content: content, textContent, - title: `${search} - Searx - Page ${page}`, + title: `"${(document.getElementById('q') as HTMLInputElement).value}" - Searx - Page ${page}`, }; } diff --git a/packages/plugins/src/engines/stackoverflow/questions.tsx b/packages/plugins/src/engines/stackoverflow/questions.tsx index bf34db8..3bd47e2 100644 --- a/packages/plugins/src/engines/stackoverflow/questions.tsx +++ b/packages/plugins/src/engines/stackoverflow/questions.tsx @@ -35,28 +35,25 @@ function postParser(el: Element | null): string { const body = el.querySelector('.js-post-body')?.innerHTML || ''; const voteCount = el.querySelector('.js-vote-count')?.textContent || ''; - const footer = [...el.querySelectorAll('.post-signature')] - .map((el) => { - const userName = el.querySelector('.user-details a')?.textContent || ''; - const userUrl = - (el.querySelector('.user-details a') as HTMLAnchorElement)?.href || ''; - const userTitle = - el.querySelector('.user-action-time')?.textContent || ''; + const footer = [...el.querySelectorAll('.post-signature')].map((el) => { + const userName = el.querySelector('.user-details a')?.textContent || ''; + const userUrl = + (el.querySelector('.user-details a') as HTMLAnchorElement)?.href || ''; + const userTitle = el.querySelector('.user-action-time')?.textContent || ''; - return ( -

- {userTitle} - {userUrl ? ( - <> - by {userName} - - ) : ( - <> - )} -

- ); - }) - .join(''); + return ( +

+ {userTitle} + {userUrl ? ( + <> + by {userName} + + ) : ( + <> + )} +

+ ); + }); return ( <> diff --git a/packages/plugins/tsconfig.json b/packages/plugins/tsconfig.json index c810653..b4a1192 100644 --- a/packages/plugins/tsconfig.json +++ b/packages/plugins/tsconfig.json @@ -3,9 +3,9 @@ /* Visit https://aka.ms/tsconfig to read more about this file */ /* Projects */ - // "incremental": true /* Save .tsbuildinfo files to allow for incremental compilation of projects. */, - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + "incremental": true /* Save .tsbuildinfo files to allow for incremental compilation of projects. */, + // "composite": true /* Enable constraints that allow a TypeScript project to be used with project references. */, + "tsBuildInfoFile": "./.tsbuildinfo" /* Specify the path to .tsbuildinfo incremental compilation file. */, // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ diff --git a/packages/sdk/src/jsx.ts b/packages/sdk/src/jsx.ts index 5f3b579..8dcc30c 100644 --- a/packages/sdk/src/jsx.ts +++ b/packages/sdk/src/jsx.ts @@ -1,19 +1,19 @@ -// eslint-disable-next-line @typescript-eslint/no-namespace +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-namespace */ export namespace JSX { export type Element = string; export interface IntrinsicElements { - // eslint-disable-next-line @typescript-eslint/no-explicit-any [elemName: string]: any; } } export function createElement( - // 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[] + ...inner: any[] ) { + const content = inner.flat().join(''); + if (typeof name === 'string') { props = props || {}; const propsstr = Object.keys(props) @@ -24,12 +24,12 @@ export function createElement( }) .join(' '); - return content.length === 0 + return inner.length === 0 ? `<${name} ${propsstr}/>` - : `<${name} ${propsstr}>${content.join('')}`; + : `<${name} ${propsstr}>${content}`; } else if (typeof name === 'function') { - return name(props, ...content); + return name(props, content); } else { - return content.join(''); + return content; } } diff --git a/packages/sdk/tsconfig.json b/packages/sdk/tsconfig.json index 073c804..f6d630c 100644 --- a/packages/sdk/tsconfig.json +++ b/packages/sdk/tsconfig.json @@ -3,9 +3,9 @@ /* Visit https://aka.ms/tsconfig to read more about this file */ /* Projects */ - // "incremental": true /* Save .tsbuildinfo files to allow for incremental compilation of projects. */, - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + "incremental": true /* Save .tsbuildinfo files to allow for incremental compilation of projects. */, + // "composite": true /* Enable constraints that allow a TypeScript project to be used with project references. */, + "tsBuildInfoFile": "./.tsbuildinfo" /* Specify the path to .tsbuildinfo incremental compilation file. */, // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ diff --git a/packages/server/tsconfig.json b/packages/server/tsconfig.json index b7d87b0..f772019 100644 --- a/packages/server/tsconfig.json +++ b/packages/server/tsconfig.json @@ -3,9 +3,9 @@ /* Visit https://aka.ms/tsconfig to read more about this file */ /* Projects */ - // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + "incremental": true /* Save .tsbuildinfo files to allow for incremental compilation of projects. */, + // "composite": true /* Enable constraints that allow a TypeScript project to be used with project references. */, + "tsBuildInfoFile": "./.tsbuildinfo" /* Specify the path to .tsbuildinfo incremental compilation file. */, // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */