nitropage
Version:
A free and open source, extensible visual page builder based on SolidStart.
14 lines (11 loc) • 448 B
text/typescript
import { createAsync, query } from "@solidjs/router";
import { Accessor } from "solid-js";
import { getLayout as getLayout_ } from "../lib/server/layout";
export const getLayout = query(async (id: string) => {
"use server";
return await getLayout_(id);
}, "np-layout");
export const useLayout = (id: Accessor<string | undefined | null>) =>
createAsync(async () => (id() ? await getLayout(id()!) : undefined), {
deferStream: true,
});