import { getTitlePrefix } from "@/utils/metadata/title/getTitlePrefix"

import type { Metadata } from "next"

export async function generateMetadata(): Promise<Metadata> {
  return {
    title: {
      template: combineSegments([getTitlePrefix(), "%s", "Scandic Hotels"]),
      default: combineSegments([getTitlePrefix(), "Scandic Hotels"]),
    },
  }
}

export default async function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return <>{children}</>
}

function combineSegments(
  segments: (string | null | undefined)[],
  delimiter = " | "
) {
  return segments.filter(Boolean).join(delimiter).trim()
}
