Reputation: 1481
Let's say I have a page from a collection where I want to list every yaml tag from a different pages collection. If they were in the same collection this would do the trick:
<section class="see-also">
<header>Related Contents:</header>
{{#each tags}}
<p>In <span class="tag">{{tag}}</span>:</p>
{{#each pages}}
<li><a href="{{relative ../../../page.dest dest}}">{{data.title}}</a></li>
{{/each}}
{{/each}}
</section>
But since im trying to access this collection from a page on a different one, how could this be achieved?
Upvotes: 3
Views: 910
Reputation: 1515
If I had this use case I would probably put the 'pages' yaml in a separate yml file instead of embedded on the page.
If in your gruntfile you include a path to data files:
assemble: {
options: {
data: ['<%= site.data %>', 'data/*.yml']
}
}
And your file structure includes:
── data
│ └── page1.yml
│ └── page2.yml
You can access {{#each page1.pages}}
from anywhere.
Or you could have a shared.yml
file that includes information like the pages collection referred to, and the rest of the data stays on each page.
Further resources:
Upvotes: 0
Reputation: 11007
I would recommend creating a custom helper for this. Since there is no easy way to write a helper that will work the way you're describing for your specific setup, here is a great example of how a custom helper was used to solve a similar problem: https://github.com/assemble/assemble/issues/254
Upvotes: 1