import { Helmet } from 'react-helmet-async';

import useHuGoTheme from 'src/hooks/useHuGoTheme';
import { formatTitle } from 'src/utils/helmetUtils';

type BaseLayoutProps = {
  title: string;
  children?: React.ReactNode;
};

const BaseLayout = ({ children, title }: BaseLayoutProps) => {
  const HuGoThemeProvider = useHuGoTheme();

  return (
    <HuGoThemeProvider>
      <Helmet>
        <title>{formatTitle(title)}</title>
      </Helmet>
      {children}
    </HuGoThemeProvider>
  );
};

export default BaseLayout;
