Help:Shortcode Ln

Create a link which shows the page name and lead, it links to.

Ln
Shortcode
Description
TypeHTML Shortcode
Nested?false
Shortcodeln
Return TypeHTML
Short Description
Display a box like button which shows the page name and lead, it links to
Development
MaintainerMichael Sasser

Use the shortcode ln to display a box which works like a button and shows the page name in the front and the page lead in small at the end.

Parameters

The Ln shortcode has the following parameters:

ParameterDescription
[0]The path to a page, with or without a file extension, with or without an anchor. A path without a leading / is first resolved relative to the given context, then to the remainder of the site.

Examples

{{< ln "wiki/Help:Shortcode_Ln" >}}
Rendered
Help:Shortcode Ln
Create a link which shows the page name and lead, it links to.

Code

Below you find the implementation of the shortcode.

HTML

Defined in layouts/shortcodes/ln.html.

This code is licensed under the MIT license.
<!-- 

  Ln Shortcode
  ============

  Contributors: Michael Sasser
  Maintainer: Michael Sasser
  License: MIT
  Version: 1
  Child Shortcodes: None
  Parent Shortcodes: None

  LAYOUT: /layout/shortcodes/ln.html
  STYLE:  /assets/scss/components/_shortcode_ln.scss
  DOCS:   /content/<language>/wiki/Help:Shortcode_Ln.md

  Description
  -----------
  Display a box like button which shows the page name and lead, it links to

  Changelog
  =========

  Version 1 (2022-07-27)
  ----------------------

  Initial release

-->


{{ $path := (index .Params 0) }}

{{ if $path }}
  {{ with .Site.GetPage $path }}
    <div class="mp-ln">
      <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
        <path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/>
      </svg>
      <div class="title">
          {{ with .Title }}
            {{ . }}
          {{ end }}
      </div>
      <div class="mp-ln-info">
        {{ with .Params.lead }}
          {{ . | safeHTML | truncate 80 }}
        {{ end }}
      </div>
      <a href="{{ with .Site.GetPage $path }}{{ .RelPermalink }}{{ end }}"></a>
    </div>
  {{ else }}
      {{ errorf "Failed to process ln shortcode: %s. The link \"%s\" does not exist." $.Position $path }}
  {{ end }}
{{ else }}
      {{ errorf "Failed to process ln shortcode: %s. No link was given to ln as parameter." $.Position }}
{{ end }}

Download

Copy the source code above or use the download link below to use this file on your website according to the license.

  • Ln Shortcode
    ln.html1.51 KB
  • md5   573c7e62dfefa147730d2d65da924878
  • sha1   65b7c609af82fdfc3f8b445585d91b9698970c2e
  • sha256   9843c57ed8eec4174fd012e532f78606ee3d2141d47b2ade760cd8532efc4dee

SASS

Defined in: /assets/scss/components/_shortcode_ln.scss

This code is licensed under the MIT license.
/*

  Ln Shortcode
  ============

  Contributors: Michael Sasser
  Maintainer: Michael Sasser
  License: MIT
  Version: 1
  Child Shortcodes: None
  Parent Shortcodes: None

  LAYOUT: /layout/shortcodes/ln.html
  STYLE:  /assets/scss/components/_shortcode_ln.scss
  DOCS:   /content/<language>/wiki/Help:Shortcode_Ln.md

*/

.mp-ln {
  border: 1px solid $border-color;
  padding: 1rem;
  border-radius: 5px;
  color: $link-color;
  display: flex;
  margin: 1em 0;
  transition: 0.1s ease-in;
  justify-content: space-between;
  align-items: center;
  position: relative;

  &:hover {
    cursor: pointer;
    border: 1px solid darken($border-color, 12%);
  }

  .title {
    padding-left: 0.5em;
  }

  .mp-ln-info {
    margin-left: auto;
    padding-right: 0.5em;
    color: $gray-500;
    font-size: $font-size-sm;
  }

  a {
    display: block;
    position: absolute;
    width: 100%;
    height: 100%;

    &:hover {
      cursor: pointer;
      text-decoration: none;
    }
  }
}

@include color-mode(dark) {
  body .mp-ln {
    border: 1px solid $border-dark;
    color: $link-color-dark;

    &:hover {
      border: 1px solid lighten($border-dark, 5%);
    }
  }

  body .mp-ln .mp-ln-info {
    color: $gray-600;
  }
}

Download

Copy the source code above or use the download link below to use this file on your website according to the license.

  • Ln Style
    _shortcode_ln.scss1.23 KB
  • md5   c1fe984aa877c4178416873e1ef3327b
  • sha1   9107af3ab7b0fb3d806132516450d0473aca87cf
  • sha256   0ae951ff245412f30be79c65732557aede53ede7e0399a99463b2280dfc27d96
Top