fumadocs-ui
Version:
The Radix UI version of Fumadocs UI
41 lines (40 loc) • 1.43 kB
JavaScript
"use client";
import { baseSlots } from "../shared/client.js";
import { useLinkItems } from "../shared/index.js";
import { Container } from "./slots/container.js";
import { Header } from "./slots/header.js";
import { jsx, jsxs } from "react/jsx-runtime";
import { createContext, use } from "react";
//#region src/layouts/home/index.tsx
const LayoutContext = createContext(null);
function useHomeLayout() {
const context = use(LayoutContext);
if (!context) throw new Error("Please use this component under <HomeLayout /> (`fumadocs-ui/layouts/home`).");
return context;
}
const { useProvider } = baseSlots({ useProps() {
return useHomeLayout().props;
} });
function HomeLayout(props) {
const { nav: { enabled: navEnabled = true } = {}, slots: defaultSlots, children, i18n: _i18n, githubUrl: _githubUrl, links: _links, themeSwitch: _themeSwitch, searchToggle: _searchToggle, ...rest } = props;
const { baseSlots, baseProps } = useProvider(props);
const linkItems = useLinkItems(props);
const slots = {
...baseSlots,
header: defaultSlots?.header ?? Header,
container: defaultSlots?.container ?? Container
};
return /* @__PURE__ */ jsx(LayoutContext, {
value: {
props: baseProps,
slots,
...linkItems
},
children: /* @__PURE__ */ jsxs(slots.container, {
...rest,
children: [navEnabled && /* @__PURE__ */ jsx(slots.header, {}), children]
})
});
}
//#endregion
export { HomeLayout, useHomeLayout };