{# Navigation Components Reusable macro-based navigation components for the Bengal default theme. Components: - breadcrumbs(page): Hierarchical breadcrumb navigation - pagination(current_page, total_pages, base_url): Page number controls - page_navigation(page): Sequential prev/next page links - section_navigation(page): Section statistics and subsection cards - toc(toc_items=None, toc=None, page=None): Table of contents sidebar Usage: {% from 'partials/navigation-components.html' import breadcrumbs, pagination %} {{ breadcrumbs(page) }} {{ pagination(current_page=2, total_pages=10, base_url='/blog/') }} #} {# Breadcrumbs Component Displays hierarchical navigation showing the current page's location in the site structure. Args: page: Current page object (required) Example: {{ breadcrumbs(page) }} #} {% macro breadcrumbs(page) %} {% set breadcrumb_items = get_breadcrumbs(page) %} {% if breadcrumb_items %} {% endif %} {% endmacro %} {# Pagination Component Displays page number controls for paginated content with prev/next buttons. Args: current_page: Current page number (1-indexed, required) total_pages: Total number of pages (required) base_url: Base URL for pagination (e.g., '/blog/', required) Example: {{ pagination(current_page=2, total_pages=10, base_url='/blog/') }} #} {% macro pagination(current_page, total_pages, base_url) %} {% if total_pages > 1 %} {% set p = get_pagination_items(current_page, total_pages, base_url) %} {% endif %} {% endmacro %} {# Page Navigation Component Displays previous/next page links for sequential navigation through content. Intelligently chooses navigation scope based on content type: - doc, tutorial, api-reference, cli-reference: Section-scoped navigation (respects weight order) - blog, page, others: Global navigation (chronological order) Args: page: Current page object with prev and next attributes (required) Example: {{ page_navigation(page) }} #} {% macro page_navigation(page) %} {# Determine which navigation to use based on content type #} {% set content_type = page.metadata.get('type', 'page') %} {% set section_types = ['doc', 'tutorial', 'api-reference', 'cli-reference', 'changelog'] %} {% set use_section_nav = content_type in section_types %} {% if use_section_nav %} {# Section-scoped navigation (within same section, respects weight) #} {% if page.prev_in_section or page.next_in_section %} {% endif %} {% else %} {# Global navigation (across entire site, chronological) #} {% if page.prev or page.next %} {% endif %} {% endif %} {% endmacro %} {# Section Navigation Component Displays statistics and subsection cards for exploring a section hierarchy. Args: page: Current page/section object (required) Note: This component expects a Section object with regular_pages and sections attributes. The variable name 'page' is maintained for backwards compatibility but should be 'section'. Example: {{ section_navigation(page) }} #} {% macro section_navigation(page) %} {% if page.regular_pages is defined or page.sections is defined %}
{% endif %} {% endmacro %} {# Table of Contents Sidebar Component Interactive table of contents with progress tracking, collapsible sections, and page metadata. Args: toc_items: List of TOC items with id, title, level (optional, defaults to None) toc: HTML TOC fallback (optional, defaults to None) page: Current page object for metadata (optional, defaults to None) Example: {{ toc(toc_items=toc_items, page=page) }} #} {% macro toc(toc_items=None, toc=None, page=None) %} {% endmacro %}