Support reference-style links in shortcodes

I had some troubles adding reference-style links to shortcodes (renders as plain text). I read this one: “Markdown Reference Links in Shortcodes - support - HUGO” and I was wondering if this is something that will be supported in the future?

I.e. Syntax below to be supported:

# Some markdown

{{<admonition-shortode type="note" >}}

 See: [This reference style link][1] to solve your issue. 

{{</admonition-shortode>}}

[1]: https://google.com

Thanks for a great tool! Making documentation really fun.

Please post the source of layouts/shortcodes/admonition-shortode.html.

Assuming your shortcode does something like this:

{{ .Inner | .Page.RenderString }}

Your Markdown needs to look like this:

{{< admonition-shortode type="note" >}}
See: [This reference style link][1] to solve your issue.

[1]: https://google.com
{{</admonition-shortode>}}

Also note that you can create admonitions with:

Yes that works. I wonder though if the syntax of having a reference-style link listed outside of a shortcode, then linking to an entry in that list inside of a shortcode will be supported. The problem is that It’s not possible to be DRY when having a lot of links on a page.

Using the below in /layouts/shortcodes/admonition-shortcode.html
`{{- $allowedTypes := slice “warning” “caution” “note” “troubleshooting” “tip” -}}
{{- $type := .Get “type” -}}
{{- $typeClass := lower $type -}}
{{- if not (in $allowedTypes $typeClass) -}}
{{ $typeString := delimit $allowedTypes ", " }}
{{- errorf “[admonition] wrong or empty value for ‘type’ (use one of %s): %s” $typeString .Position -}}
{{- end -}}
{{- $title := .Get “title” }}
{{- $inner := .Inner }}

{{- $icons := (dict
“warning” “icon-triangle-warning”
“caution” “icon-triangle-warning”
“note” “icon-info”
“troubleshooting” “icon-bug”
“tip” “icon-lightbulb”
) -}}

{{- if $title -}} {{ $title | .Page.RenderString }} {{- else -}} {{ $typeClass | title }}  {{- end }}
{{- if $title -}}
{{- $typeClass | title }}
{{- end -}}
{{- if gt (len .Inner) 0 }}
{{- .InnerDeindent | markdownify -}}
{{- end }}
`

Yes, I saw, the new way todo admonitions and it’s awesome :slight_smile:

It will not.

Also, when posting to this forum, please wrap your examples (code, data, configuration, markup, etc.) within triple backticks, or use the </> button in the menu.

```
example
```
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.