Add _data sub-folder support to docs
This commit is contained in:
parent
604fb3286c
commit
418c978b91
|
@ -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 %}
|
||||
|
|
Loading…
Reference in New Issue