mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
added minimal astro adapter + improved the example
This commit is contained in:
21
app/src/adapter/astro/astro.adapter.ts
Normal file
21
app/src/adapter/astro/astro.adapter.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Api, type ApiOptions } from "bknd";
|
||||
|
||||
type TAstro = {
|
||||
request: {
|
||||
url: string;
|
||||
headers: Headers;
|
||||
};
|
||||
};
|
||||
|
||||
export type Options = {
|
||||
mode?: "static" | "dynamic";
|
||||
} & Omit<ApiOptions, "host"> & {
|
||||
host?: string;
|
||||
};
|
||||
|
||||
export function getApi(Astro: TAstro, options: Options = { mode: "static" }) {
|
||||
return new Api({
|
||||
host: new URL(Astro.request.url).origin,
|
||||
headers: options.mode === "dynamic" ? Astro.request.headers : undefined
|
||||
});
|
||||
}
|
||||
1
app/src/adapter/astro/index.ts
Normal file
1
app/src/adapter/astro/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./astro.adapter";
|
||||
@@ -135,10 +135,10 @@ type FormInputElement = HTMLInputElement | HTMLTextAreaElement;
|
||||
function EntityFormField({ fieldApi, field, action, data, ...props }: EntityFormFieldProps) {
|
||||
const handleUpdate = useEvent((e: React.ChangeEvent<FormInputElement> | any) => {
|
||||
if (typeof e === "object" && "target" in e) {
|
||||
console.log("handleUpdate", e.target.value);
|
||||
//console.log("handleUpdate", e.target.value);
|
||||
fieldApi.handleChange(e.target.value);
|
||||
} else {
|
||||
console.log("handleUpdate-", e);
|
||||
//console.log("handleUpdate-", e);
|
||||
fieldApi.handleChange(e);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user