Sha256: c04b5c8e3eb47e6717f7c00a7e8eb073d4943cf19ac598f192e5246ff7a74bcf

Contents?: true

Size: 1.93 KB

Versions: 3

Compression:

Stored size: 1.93 KB

Contents

{%- if page.page_img %}
<div id="page-img" class="d-flex flex-column">
{%- capture file_url -%}
{{ "/images/" | append: page.page_img | relative_url }}
{%- endcapture -%}
<div class="mb-4"><img src="{{ file_url }}" alt="Page image" class="page-img-lg"/></div>
{% endif %}
{%- if page.page_img %}
</div>
{% endif %}
{%- if page.toc or page.toc == nil %}
<script>
  $(document).ready(function () {
    // Ensure that the TOC is generated after the document is fully loaded
    $('#toc-contents').toc({
      minimumHeaders: {{ site.theme_variables.toc.min_headings | default: 1 }},
      listType: 'ul',
      classes: { list: 'list-unstyled mb-4' },
      showSpeed: 0,
      headers: '{{site.theme_variables.toc.headings | default: "main h2" }}',
      title: '<strong class="my-2">On this page</strong><hr class="my-2">' 
    });
    // After generating the TOC, check the hash in the URL and scroll to the anchor if present
    if (window.location.hash) {
      var target = $(window.location.hash);
      if (target.length) {
        $('html, body').animate({
          scrollTop: target.offset().top
        }, 0);
      }
    }
    // Allow the browser to handle the scrolling to the anchor
    $('#toc-contents a').on('click', function (e) {
      e.preventDefault(); // Prevent the default link click behavior

      var target = this.hash; // Get the hash (e.g., #heading-id)
      var $target = $(target); // Find the element with the corresponding ID

      if ($target.length) {
        // Change the URL hash
        window.location.hash = target;
      }
    });

  });
</script>
<button id="btn-toc-hide" class="btn bg-light me-auto d-xl-none hover-primary mb-3" type="button" data-bs-toggle="collapse" data-bs-target="#toc-contents" aria-expanded="true" aria-controls="toc-contents">
  <i class="fa-solid fa-up-right-and-down-left-from-center me-2"></i>On this page
</button>
<nav id="toc-contents" class="collapse" aria-label="Table of contents"></nav>
{% endif %}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
elixir-toolkit-theme-4.2.0 _includes/toc.html
elixir-toolkit-theme-4.1.0 _includes/toc.html
elixir-toolkit-theme-4.0.0 _includes/toc.html