@jossmac/lil-libs
    Preparing search index...

    Function ariaCurrent

    • Determines the appropriate aria-current value for a link href against the current pathname.

      Returns "page" for exact matches, "true" for child routes (for example /about/team under /about), and "false" otherwise. Trailing slashes are normalized (except for root /).

      • pathname: string | null

        Current route pathname to test, or null for "false".

      • href: string

        Link href to compare against; trailing slashes are normalized (except root /).

      "page" for an exact match, "true" when pathname is a child route of href, otherwise "false".

      ariaCurrent("/about", "/about"); // "page"
      ariaCurrent("/about/team", "/about"); // "true"
      ariaCurrent("/about-us", "/about"); // "false" (prefix match, not a child route)
      ariaCurrent("/contact", "/about"); // "false"
      ariaCurrent(null, "/about"); // "false"