-
I was thinking of having a front page with a list of my collections (ie. topics). Ignoring the HTML/CSS side, wondering how I'd go about that with Eleventy? Eg. my cockamamie attempt so far has been:
Big problem is I can't seem to get the data from the root file in the collection folder (ie. ski.js) And overall, the approach feels quite wrong. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
What about just doing a global data file with an array of collection names+meta? Something like a global ./_data/collectionMap.js which has: module.exports = [
{ "name": "coding", "image": "/images/thumbnails/coding.jpg", "url": "/coding/" },
{ "name": "language", "image": "...", "url": "/language/" },
{ "name": "png", "image": "...", "url": "/png/" },
{ "name": "resorts", "image": "...", "url": "/resorts/" },
{ "name": "skiing", "image": "...", "url": "/skiing/" }
]; Possibly don't even need that Then, on your homepage, just loop over the // in **index.html**
{%- for coll in collectionMap -%}
<div class="card">
<h2>{{ coll.name }}</h2>
<img src="{{ site.images }}{{ coll.image }}" />
<a href="{{ coll.url }}">Read More...</a>
</div>
{% endfor %} |
Beta Was this translation helpful? Give feedback.
What about just doing a global data file with an array of collection names+meta?
Something like a global ./_data/collectionMap.js which has:
Possibly don't even need that
url
property if it's just a slugified version of thetopic
.But it's just a simple array, so you can do whatever custom ordering you want, or keep it alphabetical. I thin…