// Directory data file: applies eleventyComputed to every template in src/
// and all subdirectories.  Provides `rootPath` — the relative prefix needed
// to reach the site root from the current page.
//
// Examples:
//   /                 → "./"
//   /about/           → "../"
//   /services/        → "../"
//   /services/painting/ → "../../"

module.exports = {
  eleventyComputed: {
    rootPath: (data) => {
      const url = data.page.url || "/";
      const depth = url.split("/").filter((s) => s.length > 0).length;
      return depth === 0 ? "./" : "../".repeat(depth);
    },
  },
};
