mirror of
https://github.com/docmost/docmost.git
synced 2026-09-11 07:56:54 +08:00
feat(beta): public spaces (#2473)
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { createContext, useContext } from "react";
|
||||
import { SharedPageTreeNode } from "@/features/share/utils.ts";
|
||||
|
||||
// What varies between the public surfaces (/docs and /share) rendered by the
|
||||
// docs shell; every shell component reads this contract instead of a feature.
|
||||
export type DocsSurface = {
|
||||
treeData: SharedPageTreeNode[] | null;
|
||||
hasSidebar: boolean;
|
||||
siteName?: string;
|
||||
homeUrl?: string;
|
||||
getNodeUrl: (node: Pick<SharedPageTreeNode, "slugId" | "name">) => string;
|
||||
showBranding: boolean;
|
||||
showEditPage: boolean;
|
||||
brandingRef?: string;
|
||||
};
|
||||
|
||||
const DocsSurfaceContext = createContext<DocsSurface | null>(null);
|
||||
|
||||
export const DocsSurfaceProvider = DocsSurfaceContext.Provider;
|
||||
|
||||
export function useDocsSurface(): DocsSurface {
|
||||
const surface = useContext(DocsSurfaceContext);
|
||||
if (!surface) {
|
||||
throw new Error("useDocsSurface must be used within DocsShell");
|
||||
}
|
||||
return surface;
|
||||
}
|
||||
Reference in New Issue
Block a user