Appearance
htmx
将 Hono 与 htmx 结合使用。
¥Using Hono with htmx.
typed-htmx
通过使用 typed-htmx,你可以编写带有 TypeScript 定义的 JSX 代码,用于定义 htmx 属性。我们可以沿用 typed-htmx 示例项目 的模式,将其与 hono/jsx 结合使用。
¥By using typed-htmx, you can write JSX with TypeScript definitions for htmx attributes. We can follow the same pattern found on the typed-htmx Example Project to use it with hono/jsx.
安装软件包:
¥Install the package:
sh
npm i -D typed-htmx在 src/global.d.ts(如果你使用的是 HonoX,则在 app/global.d.ts)中,导入 typed-htmx 类型:
¥On src/global.d.ts (or app/global.d.ts if you're using HonoX), import the typed-htmx types:
ts
import 'typed-htmx'使用 typed-htmx 定义扩展 Hono 的 JSX 类型:
¥Extend Hono's JSX types with the typed-htmx definitions:
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 {}
}
}另请参阅
¥See also