feat(sdk, plugins): jsx support
This commit is contained in:
24
packages/sdk/src/jsx.ts
Normal file
24
packages/sdk/src/jsx.ts
Normal file
@ -0,0 +1,24 @@
|
||||
// eslint-disable-next-line @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(
|
||||
name: string,
|
||||
props: { [id: string]: string },
|
||||
...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}>`;
|
||||
}
|
@ -18,6 +18,8 @@ import {
|
||||
handlerSchema,
|
||||
} from './types/handler';
|
||||
|
||||
import * as JSX from './jsx';
|
||||
|
||||
export {
|
||||
Engine,
|
||||
EngineParseError,
|
||||
@ -32,4 +34,5 @@ export {
|
||||
HandlerOutput,
|
||||
Route,
|
||||
handlerSchema,
|
||||
JSX,
|
||||
};
|
||||
|
@ -33,7 +33,7 @@ export interface HandlerOutput {
|
||||
}
|
||||
|
||||
export interface EngineOutput {
|
||||
document: Document;
|
||||
content: string;
|
||||
textContent?: string;
|
||||
title?: string;
|
||||
lang?: string;
|
||||
|
Reference in New Issue
Block a user