Sha256: 9e4dfabb617082ffbbdd79c5a7637d4b4d2cbcb273f0a8cd299faa220447d956

Contents?: true

Size: 1.97 KB

Versions: 2

Compression:

Stored size: 1.97 KB

Contents

{%- capture html_link %}
{%- comment %}
    Usage:
        {% include base/link.html name="Text link" url="#" %}

    Optional Parameters:
        * name          (string) : ""
        * url           (string) : ""
        * class         (string) : ""
        * role          (string) : ""
        * color         (string) : "primary"
        * icon          (string) : ""
        * icon_position (string) : "start"

    Output:
        Text link with consistent presentation.
{%- endcomment %}

{%- assign name          = include.name          | default: nil %}
{%- assign url           = include.url           | default: nil %}
{%- assign color         = include.color         | default: "primary" %}
{%- assign role          = include.role          | default: nil %}
{%- assign icon          = include.icon          | default: nil %}
{%- assign icon_position = include.icon_position | default: "start" %}
{%- assign class         = include.class         | default: nil %}

{%- capture html_link_elements -%}
  {%- if url == nil %}
  href="{{ page.url }}#{{ name | strip | replace: " ", "-" | strip_html | downcase }}"
  {%- else %}
    {%- if url contains "https://" or url contains "http://" %}
    href="{{ url }}"
    {%- else %}
    href="{{ site.url }}{{ site.baseurl }}{{ url }}"
    {%- endif -%}
  {%- endif -%}

  {%- if class %}
  class="{{ class }}"
  {%- else %}
  class="link-{{ color }} link-offset-3 link-offset-3-hover link-underline-{{ color }} link-underline-opacity-25 link-underline-opacity-75-hover"
  {%- endif -%}

  {%- if role %}
  role="{{ role }}"
  {%- endif -%}
  {%- endcapture -%}

  {%- capture html_link_name %}
  {%- if icon != nil %}
    {%- if icon_position == "end" -%}
    {{ name }}<i class="{{ icon }} ms-2"></i>
    {%- else -%}
    <i class="{{ icon }} me-2"></i>{{ name }}
    {%- endif -%}
  {%- else -%}
  {{ name }}
  {%- endif -%}
{%- endcapture -%}
<a {{ html_link_elements | strip_newlines | strip }}>{{ html_link_name }}</a>
{%- endcapture %}
{{- html_link -}}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jekyll-theme-centos-2.51.1.beta.56 _includes/base/link.html
jekyll-theme-centos-2.51.1.beta.55 _includes/base/link.html