picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.84k stars 614 forks source link

accessing YAML arrays #406

Closed clausbertels closed 6 years ago

clausbertels commented 6 years ago

Hi guys,

I've been trying to access some data in the Front matter array using the percent syntax. I.e.:

social: 
 - link: myname@gmail.com
   icon: email.svg
 - link: http://www.instagram.com/myname
   icon: instagram.svg
 - link: http://www.linkedin.com/in/myname
   icon: linkedin.svg

How do I get the instagram link for example? I tried %meta.social[1].link%

Thank you in advance.

PhrozenByte commented 6 years ago

I'm afraid this isn't possible. The %meta.*% syntax is meant to be a simple and convenient way of including (or rather replacing) static contents like a description or title, not for things like arrays what would require a pretty complex parser. Depending on what you're trying to achieve a Twig-based solution is probably the best way to go.

clausbertels commented 6 years ago

I'm using the front matter social in the template to display the icons in the header (much like the default content-sample). I'd like to also inline those links on the page. Since it's a small site and I only need this on one page I'm fine just using markdown link references and editing two places in the future. But I could imagine that, for a bigger site, inlining meta links could prove useful.

Thanks for letting me know I'm not crazy. I was trying so many things!

Issue resolved.

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! :+1: