Skip to content

Commit c6ccd38

Browse files
committed
🎉 feat: 0.6.5
1 parent e04d152 commit c6ccd38

File tree

6 files changed

+28
-13
lines changed

6 files changed

+28
-13
lines changed

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# 0.6.4 - 8 Sep 2023
2-
Bug fix:
3-
- Fix createElement not rendering
1+
# 0.6.5 - 11 Sep 2023
2+
Improvement:
3+
- Export `Children`, `PropsWithChildren`, `Component`, and `Fragment`
4+
- [#12](https://github.com/elysiajs/elysia-html/pull/12) Drop global flag
45

56
# 0.6.3 - 8 Sep 2023
67
Improvement:

bun.lockb

-434 Bytes
Binary file not shown.

example/index.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { Elysia } from 'elysia'
2-
import { html } from '../src/index'
2+
import { html, Fragment } from '../src/index'
33

4-
const page = `
5-
<html lang="en">
4+
const page = `<html lang="en">
65
<head>
76
<title>Hello World</title>
87
</head>
@@ -27,9 +26,9 @@ const app = new Elysia()
2726
.get('/', () => page)
2827
.get('/jsx', () => jsx)
2928
.get('/html', ({ html }) => html(page))
30-
.get('/a', () => {
29+
.get('/a', () => (
3130
<>
3231
<h1>Hello World</h1>
3332
</>
34-
})
33+
))
3534
.listen(8080)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@elysiajs/html",
3-
"version": "0.6.4",
3+
"version": "0.6.5",
44
"description": "Plugin for Elysia that add support for returning html",
55
"author": {
66
"name": "saltyAom",

src/declaration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ declare function ElysiaJSX(...params: any[]): string
1010

1111
declare namespace JSX {
1212
// @ts-ignore
13-
type Element = string;
13+
type Element = string
1414

1515
// @ts-ignore
1616
type BaseHTMLTag = Record<string, unknown>

src/index.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import * as D from 'dompurify'
44

55
const sanitize = D.sanitize
66

7-
const { compile } = require('@kitajs/html')
8-
97
import './declaration'
108

119
const isHTMLRegex = /<[^>]*>/g
@@ -33,6 +31,23 @@ export const html = () =>
3331
}
3432
})
3533

36-
export type { PropsWithChildren } from '@kitajs/html'
34+
export declare type Children =
35+
| number
36+
| string
37+
| boolean
38+
| null
39+
| undefined
40+
| Children[]
41+
42+
export declare type PropsWithChildren<T = {}> = { children?: Children } & T
43+
44+
export declare type Component<T = {}> = (
45+
this: void,
46+
props: PropsWithChildren<T>
47+
) => JSX.Element
48+
49+
const { Fragment: F } = require('@kitajs/html')
50+
51+
export const Fragment = F as Component
3752

3853
export default html

0 commit comments

Comments
 (0)