How to get variables programtically?

I want to do something like this:

$.Site.Data.[.Params.data]

For example:
I have 3 files:

/data/Social.json

{
	"twitter": "https://twitter.com/intent/tweet?text=tweet%20something%20-%20{url}",
	"linkedin": "https://www.linkedin.com/shareArticle?mini=true&url={url}&title=title&summary=summary"
}

/content/article.md

---
shareOn: 'twitter'
---

/layouts/baseof.html

{{ $.Site.Data.Social.[.Params.shareOn] }}

Result is expected to return https://twitter.com/intent/tweet?text=tweet%20something%20-%20{url}

Is there anyway to do so?

[Update - same date - 11h +7] Add context. Sorry about this, I wrote this on tablet so it’s lack of context. I hope my update will make my question be more clear. Btw, @zwbetz suggestion seems like the one I need. I will report immediately after I try it. Thanks :slight_smile:

You’ll need to give a little more information for us to help. Maybe a copy of the data file and a snippet of the code you’re using to process it. Or even better, a link to your whole repository.

1 Like

As @funkydan2 mentioned, we need more context.

Off the top of my head, though, try something like:

{{ index $.Site.Data .Params.data }}

If your .Params.data had a value of foo, then the above would be equivalent to:

{{ $.Site.Data.foo }}
2 Likes