import type { ComponentType, ReactNode } from 'react';

export type PageLayout = ComponentType<{ children: ReactNode }> | null;

/**
 * The layout wrapped around pages that do not name one themselves. rutatiina/themes
 * sets it; a page opts out with `export const layout = null`.
 */
let defaultLayout: PageLayout = null;

export function setDefaultLayout(layout: PageLayout): void {
  defaultLayout = layout;
}

export function getDefaultLayout(): PageLayout {
  return defaultLayout;
}
