summaryrefslogtreecommitdiff
path: root/layouts/_shortcodes
diff options
context:
space:
mode:
Diffstat (limited to 'layouts/_shortcodes')
-rw-r--r--layouts/_shortcodes/descrlist.html20
-rw-r--r--layouts/_shortcodes/newtab.html7
2 files changed, 27 insertions, 0 deletions
diff --git a/layouts/_shortcodes/descrlist.html b/layouts/_shortcodes/descrlist.html
new file mode 100644
index 0000000..99517c3
--- /dev/null
+++ b/layouts/_shortcodes/descrlist.html
@@ -0,0 +1,20 @@
+{{- /*
+ Description list for a dynamic number of term-details pairs
+
+ @context {string} class: CSS class name
+ @context {string} entries: semicolon-separated pairs of "title=description"
+
+ @example: {{< descrlist class="dl-borders-centered" entries="Author=William Shakespeare;Title=Macbeth;Year of Publication=1606" >}}
+*/ -}}
+<dl{{ with .Get "class" }} class="{{ . }}" {{ end }}>
+{{- $pairs := split (.Get "entries") ";" -}}
+ {{- range $pairs -}}
+ {{- $currentPairSplit := split . "=" -}}
+ <dt>
+ {{ index $currentPairSplit 0 }}
+ </dt>
+ <dd>
+ {{ index $currentPairSplit 1 }}
+ </dd>
+ {{- end -}}
+</dl>
diff --git a/layouts/_shortcodes/newtab.html b/layouts/_shortcodes/newtab.html
index b06fb2d..3f3fe75 100644
--- a/layouts/_shortcodes/newtab.html
+++ b/layouts/_shortcodes/newtab.html
@@ -1,3 +1,10 @@
+{{- /*
+ Link that opens a new tab; protects current window & hides referrer URL
+
+ @context {string} href: target URL
+
+ @example: {{< newtab href="https://some-site.com" >}}Some text to be displayed{{< /newtab >}}
+*/ -}}
<a href="{{ .Get "href" }}" target="_blank" rel="noopener noreferrer">
{{ .Inner }}
</a>