Shortcode for link to file with title as link text

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>
    <a href="{{- ref . (.Get 0) -}}">{{- .Inner -}}</a>

To use this shortcode, I insert {{% adoc_ref "aFile.adoc" %}}Analyzing Data{{% /adoc_ref %}}

You could use .Site.GetPage to get the page by the filename passed in. Then get the .Title from the page. Then build your <a> element.

For example, something like this:

{{ $page := .Site.GetPage (.Get "filename") }}
{{ $anchor := printf "<a href=\"%s\">%s</a>" $page.Permalink $page.Title }}
{{ $anchor | safeHTML }}

Then use it like:

{{< shortcodename filename="" >}}

Works exactly as advertised! Thanks!