Using relref with another shortcode

I have a shortcode which produces the latest version of a product. However, I can’t simply use that within the relref shortcode (that is, something like {{< relref "base/{{< version >}}/topic.md" >}} will not work).

Has anyone else created a version of relref that evaluates shortcodes within the URL?

p.

what you want to do is not possible with shortcodes in Markdown.

You will have to write your own customized variant. The implementation depends on what that one does or is intended to do? looks like you “calculate” the version somehow

basic steps could be:

  • create your own shortcode versionedRelRef passing fe base and topic
  • calculate the version within (you have access to the page here) $version := ...
  • construct the path $path := urls.JoinPath .Params.base $version .Params topic
  • call the Shortcodes RelRef method or the relref function .RelRef $path
  • and return the result

variants:

  • passing a KEY to replace with version as {{ versiondRelRef "base/VERSION/topic.md)

the default Relref shortcode implementation itself is not really complicated. see source link in the docs