import { readFileSync } from "node:fs";

type Pkg = { version?: string };

function readPkgVersion(): string {
  try {
    const raw = readFileSync(new URL("../../package.json", import.meta.url), "utf-8");
    const pkg = JSON.parse(raw) as Pkg;
    return pkg.version ?? "0.0.0";
  } catch {
    return "0.0.0";
  }
}

export const SITE_RELEASE = process.env.PUBLIC_RELEASE || readPkgVersion();
export const BUILD_TIME_ISO = new Date().toISOString();
