diff --git a/site/_docs/collections.md b/site/_docs/collections.md index c8dd4455..f626fe31 100644 --- a/site/_docs/collections.md +++ b/site/_docs/collections.md @@ -37,6 +37,17 @@ collections: foo: bar {% endhighlight %} +Default attributes can also be set for a collection: + +{% highlight yaml %} +defaults: + - scope: + path: "" + type: my_collection + values: + layout: page +{% endhighlight %} + ### Step 2: Add your content Create a corresponding folder (e.g. `/_my_collection`) and add @@ -203,7 +214,7 @@ you specified in your `_config.yml` (if present) and the following information:

- The path to the collections's source directory, relative to the site + The path to the collection's source directory, relative to the site source.

@@ -319,3 +330,47 @@ file, each document has the following attributes: + +## Accessing Collection Attributes + +Attributes from the YAML front matter can be accessed as data anywhere in the site. Using the above example for configuring a collection as `site.albums`, one might have front matter in an individual file structured as follows (which must use a supported markup format, and cannot cannot be saved with a `.yaml` extension or the like): + +{% highlight yaml %} +title: "Josquin: Missa De beata virgine and Missa Ave maris stella" +artist: "The Tallis Scholars" +director: "Peter Phillips" +works: + - title: "Missa De beata virgine" + composer: "Josquin des Prez" + tracks: + - title: "Kyrie" + duration: "4:25" + - title: "Gloria" + duration: "9:53" + - title: "Credo" + duration: "9:09" + - title: "Sanctus & Benedictus" + duration: "7:47" + - title: "Agnus Dei I, II & III" + duration: "6:49" +{% endhighlight %} + +Every album in the collection could be listed on a single page with a template: + +{% highlight html %} +{% raw %} +{% for album in site.albums %} +

{{ album.title }}

+

Performed by {{ album.artist }}{% if album.director %}, directed by {{ album.director }}{% endif %}

+ {% for work in album.works %} +

{{ work.title }}

+

Composed by {{ work.composer }}

+ + {% endfor %} +{% endfor %} +{% endraw %} +{% endhighlight %}