const globalClickHandler = (navigate) => (e) => {
  const target = e.path[0];
  if (e.ctrlKey || e.metaKey) return;
  if ('useRouter' in target.dataset) {
    e.preventDefault();
    navigate(target.href);
  }
};

/**
 * Facilitates navigation within the application and initializes
 * page views based on the matched routes.
 */
export default class Router {
  /**
   *
   * @param {object} context Any initial context to be passed to pages.
   */
  constructor(context = {}) {
    this.routes = [];
    this.context = context;
    this.currentPage = null;

    window.addEventListener('popstate', (e) => {
      this.renderPage(e.state.href, true);
    });

    // Toggle menu open.
    document.querySelector('.site-header--hamburger-btn').addEventListener('click', () => {
      document.querySelector('.site-header').classList.toggle('open');
      document.body.classList.toggle('disable-scroll');
    });

    // Global click listener setup
    const navigate = this.navigate.bind(this);
    document.addEventListener('click', globalClickHandler(navigate));

    this.init();
  }

  /**
   * Registers a route.
   *
   * @param {string}   path     Route path.
   * @param {Function} callback Callback method.
   */
  route(path, callback) {
    this.routes.push({ path, callback });
  }

  async init() {
    const response = await fetch('/api.json');
    const apiData = await response.json();

    this.context.apiData = apiData;
    this.context.mainContent = document.querySelector('main');
    this.context.navigate = this.navigate.bind(this);

    this.renderPage(window.location.href);
  }

  /**
   * Finds appropriate callback and executes it.
   *
   * @param {string}  href      Target URL to navigate to.
   * @param {boolean} skipState Flag indicating whether push state should be skipped.
   */
  renderPage(href = '/', skipState = false) {
    const targetUrl = new URL(href, window.location.origin);
    const foundRoute = this.routes.find(
      ({ path }) => new RegExp(path).test(targetUrl.pathname),
    );

    /**
     * Only push new state when this is a navigation between pages
     * and `skipState` is not true.
     */
    const isNavigationBetweenPages = this.currentPage !== foundRoute.callback;
    if (!skipState && isNavigationBetweenPages) {
      window.history.pushState({ href }, null, targetUrl.pathname);
    }

    window.scrollTo(0, 0);
    this.context.path = targetUrl.pathname;
    this.context.mainContent.innerHTML = '';
    this.currentPage = foundRoute.callback;
    foundRoute.callback(this.context);
  }

  /**
   * Invoked when an internal link is clicked / tapped.
   *
   * @param {string} href Target URL to navigate to.
   */
  navigate(href) {
    document.querySelector('body').classList.remove('mobile');
    this.renderPage(href);
  }
}

@@ -1,218 +1,4 @@
-const globalClickHandler = (navigate) =%3E (e) =%3E %7B%0A  const target = e.path%5B0%5D;%0A  if (e.ctrlKey %7C%7C e.metaKey) return;%0A  if ('useRouter' in target.dataset) %7B%0A    e.preventDefault();%0A    navigate(target.href);%0A  %7D%0A%7D;%0A%0A
 /**%0A
@@ -731,55 +731,8 @@
 tup%0A
-    const navigate = this.navigate.bind(this);%0A
     
@@ -770,15 +770,14 @@
 k', 
-globalC
+this.c
 lick
@@ -787,17 +787,18 @@
 dler
-(navigate
+.bind(this
 ));%0A
@@ -976,24 +976,24 @@
 callback) %7B%0A
-
     this.rou
@@ -1027,16 +1027,611 @@
 );%0A  %7D%0A%0A
+  /**%0A   * Responds to click events anywhere in the document and when%0A   * the click happens on a link that is supposed to be handled%0A   * by the router, loads and displays the target page.%0A   *%0A   * @param %7BEvent%7D e Click event.%0A   */%0A  clickHandler(e) %7B%0A    const closestParentLink = e.path.find((el) =%3E el.tagName === 'A');%0A    const isRouterLink = closestParentLink && 'useRouter' in closestParentLink.dataset;%0A    const isStandardClick = !e.ctrlKey && !e.metaKey;%0A%0A    if (isRouterLink && isStandardClick) %7B%0A      e.preventDefault();%0A      this.navigate(closestParentLink.href);%0A    %7D%0A  %7D%0A%0A
   async 

Simplify and fix router.