import 'server-only';

import { withSegmentDefaults } from '@akinon/next/hocs/server';
import ThemePlaceholder from '@akinon/pz-theme/src/theme-placeholder';
import { buildHomepagePageContext } from '@theme/utils/theme-page-context';

export const dynamic = 'force-static';
export const revalidate = 600;

const getPlaceholderSlug = (baseSlug: string) => {
  const isDevelopment = process.env.NODE_ENV === 'development';
  return isDevelopment ? `${baseSlug}-dev` : baseSlug;
};

async function Page() {
  return (
    <ThemePlaceholder
      slug={getPlaceholderSlug('homepage-body-new')}
      pageContext={buildHomepagePageContext()}
    />
  );
}

export async function generateStaticParams() {
  return [];
}

export default withSegmentDefaults(Page, { segmentType: 'page' });
