// Single source of truth for features that aren't finished yet.
//
// In production, the routes below are rewritten to an "En construction"
// placeholder by the proxy (src/proxy.ts) and their sidebar entries get a
// badge, so users on main → prod never see work-in-progress.
//
// Local `next dev` keeps the real pages so the work can continue. Set
// SHOW_WIP_FEATURES=1 to preview a production build without the block.

/** Route prefixes whose feature is still under construction. */
export const UNDER_CONSTRUCTION_PREFIXES = [
  "/content",
  "/backlink/overview",
] as const;

/** True when `pathname` is (or sits under) an under-construction route. */
export function isUnderConstruction(pathname: string): boolean {
  return UNDER_CONSTRUCTION_PREFIXES.some(
    (prefix) => pathname === prefix || pathname.startsWith(`${prefix}/`),
  );
}

/**
 * Whether the real page should be blocked. We block only where end users can
 * reach it (production builds); local dev keeps the pages so they can be built.
 */
export function constructionBlockActive(): boolean {
  if (process.env.SHOW_WIP_FEATURES === "1") return false;
  return process.env.NODE_ENV === "production";
}
