.html file is entirely YAML front matter, should be .yml? #1895
-
I have a <html lang="en">
<head>
<title>{{ title }}</title>
...
{% for camera in cameras %}
...
<div class="title">{{ camera.name }}</div>
<a href="{{ camera.url }}" target="_new">
... And it works great to generate from a collection of other ---
layout: cameras
title: City Dam Conditions
cameras:
- name: Camera One
url: img_5efb570d3e69b200189830af.jpg
--- Since all these |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I don't think there's any problem with a YAML-frontmatter only solution, but yeah, you could do a global data file and pagination if you want to reduce some redundancy. // ./src/_data/cameras.js
module.exports = [
{
title: "City Dam Conditions",
cameras: [
{ name: "Camera One", url: "camera-one.jpg" },
{ name: "Camera Two", url: "camera-two.jpg" },
],
},
{
title: "City Center Intersection",
cameras: [
{ name: "North", url: "north.jpg" },
{ name: "East", url: "east.jpg" },
{ name: "West", url: "west.jpg" },
{ name: "South", url: "south.jpg" },
],
},
]; ---
# ./src/cameras/pagination.njk
pagination:
data: cameras
size: 1
alias: site
permalink: "camera/{{ site.title | slug }}/"
layout: cameras
eleventyComputed:
title: "{{ site.title }}"
---
<h1>{{ title }} <small>({{ site.cameras.length }} cameras)</small></h1>
{% for camera in site.cameras %}
<article>
<div class="title">{{ camera.name }}</div>
<a href="{{ camera.url }}" target="_blank">{{ camera.name }}</a>
</article>
{% endfor %} |
Beta Was this translation helpful? Give feedback.
Example here 🎉