private function limitToc(&$toc, &$meta, $baseRoute = null)
    {
        $defaults = [
            "items" => 7,
            "offset" => 0,
        ];
        $options = array_merge($defaults, $meta);

        // Check if pagination is currently used
        if ($this->currentPage) {
            $options["offset"] = ($this->currentPage - 1) * $options["items"];
        }

        $meta["totalItems"] = count($toc);
        $meta["currentPage"] = (int) floor($options["offset"] / $options["items"]) + 1;
        $meta["totalPages"] = (int) floor($meta["totalItems"] / $options["items"] + 1);

        // Next and previous page
        $pagination = $this->config["pagination"];
        $meta["nextPageUrl"] = null;
        $meta["previousPageUrl"] = null;
        $baseRoute = isset($baseRoute)
            ? $baseRoute
            : $this->baseRoute;

        if ($meta["currentPage"] > 1 && $meta["totalPages"] > 1) {
            $previousPage = $meta["currentPage"] - 1;
            $previous = "";
            if ($previousPage != 1) {
                $previous = "$pagination/$previousPage";
            }
            $meta["previousPageUrl"] = "$baseRoute/$previous";
        }

        if ($meta["currentPage"] < $meta["totalPages"]) {
            $nextPage = $meta["currentPage"] + 1;
            $meta["nextPageUrl"] = "$baseRoute/$pagination/$nextPage";
        }


        // Only use slice of toc
        $startSlice = ($meta["currentPage"] - 1) * $options["items"];
        $toc = array_slice($toc, $startSlice, $options["items"]);
        $meta["displayedItems"] = count($toc);
    }