def find_frontmatter_ending(mdx: str, stop_looking_after: int = 10) -> int:
    """Find the line number where the mdx frontmatter ends.

    Args:
        mdx (str): String representation of the mdx file.
        stop_looking_after (int): Optional, default is 10. Number of lines to stop
        looking for the end of the frontmatter.

    Returns:
        int: The next line where the frontmatter ending is found.

    Raises:
        IndexError: No markdown frontmatter was found.

    """
    indices = []
    still_looking = 0
    lines = mdx.splitlines()
    for i, line in enumerate(lines):
        still_looking += 1
        if still_looking >= stop_looking_after:
            break
        if line == "---":
            indices.append(i)
            still_looking = 0
        if i == len(line) - 1:
            break

    if not indices:
        msg = "No markdown frontmatter found in the tutorial."
        raise IndexError(msg)

    return max(indices) + 1