{% if include.link.pdf %}
    {% assign link_kind = "PDF" %}
    {% unless include.link.link %}
        {% if include.link.pdf contains "://" %}
            {% assign link_url = include.link.pdf | prepend: "http://docs.google.com/gview?url=" %}
        {% else %}
            {% assign link_url = "/" | append: include.link.pdf | prepend: site.baseurl %}
        {% endif %}
    {% endunless %}
{% endif %}
{% if include.link.md %}
    {% assign link_kind = "Markdown" %}
    {% assign metadata_name = include.link.md | replace: "/", "_" | remove: " " | append: "_metadata" %}
    {% assign link_text = site.data[metadata_name].header.title | default: site.data[metadata_name].title %}
    {% assign link_description = site.data[metadata_name].header.description %}
    {% unless include.link.link %}
        {% assign link_url = "/" | append: include.link.md | prepend: site.baseurl   %}
    {% endunless %}
{% endif %}
{% if include.link.notebook %}
    {% assign link_kind = "Notebook" %}
    {% assign metadata_name = include.link.notebook | replace: "/", "_" | remove: " " | append: "_metadata" %}
    {% assign link_text = site.data[metadata_name].header.title | default: site.data[metadata_name].title %}
    {% assign link_description = site.data[metadata_name].header.description %}
    {% unless include.link.link %}
        {% assign link_url = "/" | append: include.link.notebook | prepend: site.baseurl   %}
    {% endunless %}
{% endif %}
{% if include.link.index %}
    {% assign index_tag = include.link.index | replace: "/", "_" | remove: " " %}
    {% assign link_kind = "Page" %}
    {% assign link_text = site.data[index_tag].title %}
    {% assign link_description = site.data[index_tag].description.content | default: site.data[index_tag].description | default: site.data[index_tag].header.description %}
    {% unless include.link.link %}
        {% assign link_url = "/" | append: include.link.index | prepend: site.baseurl | append: ".html" %}
    {% endunless %}
{% endif %}
{% assign link_url = include.url | default : include.link.link | default: link_url  %}
{% assign link_text = include.text | default: include.link.text | default: link_text %}
{% assign link_icon = include.icon | default: include.link.icon %}
{% assign link_description = include.description | default: include.link.description | default: link_description %}
{% assign link_kind = include.kind | default: include.link.kind | default: link_kind %}
{% unless include.grouped %}
    <a href="{{ link_url }}" class="{{include.class}}"
       {% if include.description or include.link.description %}
       data-bs-toggle="tooltip" data-bs-html="true" title="{{include.description | default : include.link.description}}"
       {% else %}
       {% if include.link.index or include.link.md or include.link.notebook %}
       data-bs-toggle="tooltip" data-bs-html="true" title="{{link_description}}"
       {% endif %}
       {% endif %}
    >
    {% if include.icon or include.link.icon %}
        <i class="{{ include.icon | default: include.link.icon }}" aria-hidden="true"></i>
    {% endif %}
    {% if include.image or include.link.image %}
        <img
            src="{{include.link.image.src | default: include.link.image | default: include.image.src | default: include.image }}"
            width="{{include.link.image.width  | default: include.link.image.size |  default: include.image.width |  default: include.image.size | default: 20 }}"
            height="{{include.link.image.height | default: include.link.image.size |  default: include.image.height |  default: include.image.size | default: 20 }}"
            class="{{include.link.image.class |  default: "d-inline-block" }}"
        >
    {% endif %}
    {% if include.text or include.link.text %}
        {{ include.text | default: include.link.text  }}
    {% else %}
        {% if include.link.index or include.link.md or include.link.notebook %}
            {{ link_text  }}
        {% endif %}
    {% endif %}
    </a>
{% else %}
    <a href="{{ link_url }}" class="list-group-item list-group-item-action p-4 m-0">
        <div class="d-flex w-100 justify-content-between py-0 my-0 p-0">
            <h5>
                {% if include.icon or include.link.icon %}
                    <i class="{{ include.icon | default: include.link.icon }}" aria-hidden="true"></i>
                {% endif %}
                {% if include.image or include.link.image %}
                    <img
                        src="{{include.link.image.src | default: include.link.image | default: include.image.src | default: include.image }}"
                        width="{{include.link.image.width  | default: include.link.image.size |  default: include.image.width |  default: include.image.size | default: 20 }}"
                        height="{{include.link.image.height | default: include.link.image.size |  default: include.image.height |  default: include.image.size | default: 20 }}"
                        class="{{include.link.image.class |  default: "d-inline-block" }}"
                    >
                {% endif %}
                {% if include.text or include.link.text %}
                    {{ include.text | default: include.link.text  }}
                {% else %}
                    {% if include.link.index or include.link.md or include.link.notebook %}
                        {{ link_text  }}
                    {% endif %}
                {% endif %}
            </h5>
            {% if include.kind or include.link.kind %}
                <small>{{include.kind | default: include.link.kind }}</small>
            {% else %}
                {% if include.link.index or include.link.md or include.link.notebook or include.link.pdf %}
                    {% if link_kind %}
                        <small>{{ link_kind  }}</small>
                    {% endif %}
                {% endif %}
            {% endif %}
        </div>
        {% if include.description or include.link.description  %}
            <div class="mb-1">
                {{ include.description | default: include.link.description }}
            </div>
        {% else %}
            {% if include.link.index or include.link.md or include.link.notebook %}
                {% if link_description %}
                    <div class="mb-1">
                        {{ link_description }}
                    </div>
                {% endif %}
            {% endif %}
        {% endif %}
    </a>
{% endunless %}