def _get_nav_from_toml(
    path: str = ".streamlit/pages.toml",
) -> list[StreamlitPage] | dict[str, list[StreamlitPage]]:
    """
    Given a path to a TOML file, return a list or dictionary that can be passed to
    st.navigation
    """
    pages = _get_pages_from_config(path)
    if pages is None:
        return []

    if HIDE_PAGES_KEY not in st.session_state:
        st.session_state[HIDE_PAGES_KEY] = []

    # Filter out pages that are in the pages_to_hide list
    pages = [
        p
        for p in pages
        if (
            p.name not in st.session_state[HIDE_PAGES_KEY]
            and str(p.name).replace("_", " ") not in st.session_state[HIDE_PAGES_KEY]
        )
        or p.is_section
    ]

    has_sections = any(p.is_section for p in pages)

    pages_data: dict[str, list[StreamlitPage]] | list[StreamlitPage] = []

    if has_sections:
        pages_data = {}

        current_section = ""

        sections_to_drop = []

        for page in pages:
            if page.is_section:
                if page.icon is not None:
                    current_section = f"{translate_icon(page.icon)} {page.name}"
                else:
                    current_section = cast(str, page.name)
                if page.name in st.session_state[HIDE_PAGES_KEY]:
                    sections_to_drop.append(current_section)
                continue
            if current_section not in pages_data:
                pages_data[current_section] = []
            pages_data[current_section].append(
                st.Page(
                    page.path,
                    title=page.name,
                    icon=translate_icon(page.icon),
                    url_path=page.url_path,
                )
            )

        for section in sections_to_drop:
            del pages_data[section]
    else:
        pages_data = []

        for page in pages:
            pages_data.append(
                st.Page(
                    page.path,
                    title=page.name,
                    icon=translate_icon(page.icon),
                    url_path=page.url_path,
                )
            )

    return pages_data
Given a path to a TOML file, return a list or dictionary that can be passed to
st.navigation
src/st_pages/__init__.py