How to access a specific item in the data folder
It's common to want to access a specific item in the data folder. this should be documented.
This commit is contained in:
parent
fa6981fb8c
commit
ac7c1d0cd6
|
@ -114,3 +114,30 @@ The organizations can then be accessed via `site.data.orgs`, followed by the fil
|
||||||
</ul>
|
</ul>
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
|
## Example: Accessing a specific author
|
||||||
|
|
||||||
|
Pages and posts can also access a specific item. The example below shows how to access a specific item:
|
||||||
|
|
||||||
|
'_data/peoplejekyll.yml':
|
||||||
|
{% highlight yaml %}
|
||||||
|
dave:
|
||||||
|
name: David Smith
|
||||||
|
link: /bitcoin-expert/
|
||||||
|
twitter: DavidSilvaSmith
|
||||||
|
{% endhighlight %}
|
||||||
|
|
||||||
|
The author can then be specified as a page variable in a post's frontmatter:
|
||||||
|
|
||||||
|
{% highlight html %}
|
||||||
|
{% raw %}
|
||||||
|
---
|
||||||
|
title: sample post
|
||||||
|
author: dave
|
||||||
|
---
|
||||||
|
|
||||||
|
{% assign author = site.data.people.[page.author] %}
|
||||||
|
<a rel="author" href="{{ author.twitter }}" title="{{ author.name }}">author.name</a>
|
||||||
|
|
||||||
|
{% endraw %}
|
||||||
|
{% endhighlight %}
|
||||||
|
|
Loading…
Reference in New Issue