diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-01-12 19:09:39 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-01-12 21:37:23 +0900 |
| commit | f3a77cb2f83ff2f91a5cc78da2bd735ad0d4edec (patch) | |
| tree | 98518452454750d6784619a9232f1f72958f6571 /vhosts/blog/nuldoc-src/jsx/jsx-runtime.ts | |
| parent | aecf316775c995f089012d8fec5c5cc77f6300be (diff) | |
| download | nsfisis.dev-f3a77cb2f83ff2f91a5cc78da2bd735ad0d4edec.tar.gz nsfisis.dev-f3a77cb2f83ff2f91a5cc78da2bd735ad0d4edec.tar.zst nsfisis.dev-f3a77cb2f83ff2f91a5cc78da2bd735ad0d4edec.zip | |
refactor(blog/nuldoc): support JSX notation in nuldoc sources
Diffstat (limited to 'vhosts/blog/nuldoc-src/jsx/jsx-runtime.ts')
| -rw-r--r-- | vhosts/blog/nuldoc-src/jsx/jsx-runtime.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/vhosts/blog/nuldoc-src/jsx/jsx-runtime.ts b/vhosts/blog/nuldoc-src/jsx/jsx-runtime.ts new file mode 100644 index 00000000..9571e87d --- /dev/null +++ b/vhosts/blog/nuldoc-src/jsx/jsx-runtime.ts @@ -0,0 +1,27 @@ +import type { Node } from "../dom.ts"; + +export type JSXElement = { + tag: string | FunctionComponent; + props: Props; +}; + +export type JSXNullNode = false | null | undefined; +export type JSXSimpleNode = JSXElement | Node | string; +export type JSXNullableSimpleNode = JSXSimpleNode | JSXNullNode; +export type JSXNode = JSXNullableSimpleNode | JSXNode[]; +export type RenderableJSXNode = JSXElement; + +type Props = { children?: JSXNode } & Record<string, unknown>; +export type FunctionComponentResult = JSXElement | Promise<JSXElement>; +type FunctionComponent = (props: Props) => FunctionComponentResult; + +export function jsx( + tag: string | FunctionComponent, + props: Props, +): JSXElement { + return { tag, props }; +} + +export { jsx as jsxs }; + +// TODO: support Fragment |
