Add _data sub-folder support to docs

This commit is contained in:
Rodrigo Dumont 2014-05-12 11:21:31 -03:00
parent 604fb3286c
commit 418c978b91
1 changed files with 44 additions and 0 deletions

View File

@ -61,3 +61,47 @@ You can now render the list of members in a template:
</ul>
{% endraw %}
{% endhighlight %}
## Example: Organizations
Data files can also be placed in sub-folders of the `_data` folder. Each folder level will be added to a variable's namespace. The example bellow shows how GitHub organizations could be defined separately in a file under the `orgs` folder:
In `_data/orgs/jekyll.yml`:
{% highlight yaml %}
username: jekyll
name: Jekyll
members:
- name: Tom Preston-Werner
github: mojombo
- name: Parker Moore
github: parkr
{% endhighlight %}
In `_data/orgs/doeorg.yml`:
{% highlight yaml %}
username: doeorg
name: Doe Org
members:
- name: John Doe
github: jdoe
{% endhighlight %}
The organizations can then be accessed via `site.data.orgs`, followed by the file name:
{% highlight html %}
{% raw %}
<ul>
{% for org in site.data.orgs %}
<li>
<a href="https://github.com/{{ org.username }}">
{{ org.name }}
</a>
({{ org.members | size }} members)
</li>
{% endfor %}
</ul>
{% endraw %}
{% endhighlight %}