import { useSiteMetadata } from "./use-site-metadata"

export const usePageUrl = (relativeDirectory: string, locale?: string) => {
  const siteUrl = useSiteMetadata().siteMetadata.siteUrl
  const path =
    relativeDirectory.indexOf("/") == 0
      ? relativeDirectory.substring(1)
      : relativeDirectory
  return `${siteUrl}/${locale}/${path}`
}
