htmx
使用 Hono 与 htmx。
typed-htmx
通过使用 typed-htmx,您可以使用 TypeScript 定义为 htmx 属性编写 JSX。我们可以遵循 typed-htmx 示例项目 中找到的相同模式,以便与 hono/jsx
一起使用它。
安装包
sh
npm i -D typed-htmx
在 src/global.d.ts
(如果您使用的是 HonoX,则为 app/global.d.ts
)中,导入 typed-htmx
类型
ts
import 'typed-htmx'
将 Hono 的 JSX 类型扩展为 typed-htmx 定义
ts
// A demo of how to augment foreign types with htmx attributes.
// In this case, Hono sources its types from its own namespace, so we do the same
// and directly extend its namespace.
declare module 'hono/jsx' {
namespace JSX {
interface HTMLAttributes extends HtmxAttributes {}
}
}