How to collect specific param from config.toml list in shortcode?

Hello everyone.

I have a config.toml that contains the following:

  name = "Github"
  icon = "fa fa-github fa-2x"
  weight = 1
  url = "LINK"
  name = "LinkedIn"
  icon = "fa fa-linkedin"
  weight = 2
  url = "LINK"
  name = "Twitter"
  icon = "fa fa-twitter"
  weight = 3
  url = "LINK"

I want to access the 2nd item’s url in a shortcode in my markdown, but I can’t figure out how.

I know I have to use this shortcode: {{< param author >}} where I replace author with my param refernce, but I can’t figure out how to access my url of specific social link object.

Can anyone help? Thanks!

(index (where "name" "LinkedIn") 0).url

Thanks for your reply! How does your code fit into the {{}} code? Do i replace “author” with what you posted?

If you want to extract this value into your content, you need to write your own shortcode.

I am grateful for your replies, but for future readers’ sake, can you post a full solution?

I was expecting to be able to use the existing param shortcode, can I not?

No, you cannot, because you are accessing a map element in an array of maps.


{{< social-link "LinkedIn" >}}


{{ $name := .Get 0 }}
{{ $url := (index (where "name" $name) 0).url }}
<a href="{{ $url }}">{{ $name }}</a>



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