I have a shortcode that makes an <a>
link to another file in my /content
directory, but at the moment I have to supply the link text myself. Since that’s error-prone, I’d like to extend the shortcode to include the title parameter of the linked file as link text.
For example, if I have content/metrics/aFile.adoc
and its front matter is
+++
title = "Analyzing Data"
date = "2018-12-10"
weight = 900
+++
For baseURL = /
I want a shortcode that yields
<a href="/metrics/aFile.html">Analyzing Data</a>
My current shortcode is
{{ if .IsNamedParams }}
<a href="{{- ref . (.Get "filename") -}}">{{- .Inner -}}</a>
{{else}}
<a href="{{- ref . (.Get 0) -}}">{{- .Inner -}}</a>
{{end}}
To use this shortcode, I insert {{% adoc_ref "aFile.adoc" %}}Analyzing Data{{% /adoc_ref %}}