Closed zslabs closed 8 years ago
There's a few errors.
layouts/default.html
you have {{{contents}}}
which isn't a thing in handlebars-layouts. Anywhere you want to have content injected into a layout should be defined as a block.src/pages/index.md
you lead the document with an {{#extend}}
, but then have content after that. This is also not valid as your content isn't set to be injected into a block.I think what you're trying for is more like this:
// layouts/default.html
<!doctype html>
<html lang="en">
<head>
{{> head}}
</head>
<body>
<h1>Default Layout</h1>
{{#block "header"}}{{/block}}
{{#block "body"}}{{/block}}
{{> footer}}
</body>
</html>
// partials/head.html
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{{title}}</title>
<script src="//cdn.polyfill.io/v2/polyfill.min.js"></script>
// partials/footer.html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.min.js"></script>
// src/pages/index.md
---
title: Homepage
---
{{#extend "default"}}
{{#content "header"}}
<h1>Hello there</h1>
{{/content}}
{{#content "body"}}
<ul>
{{#if collections.articles}}
{{#each collections.articles}}
<li>
<h3>{{this.title}}</h3>
<article>{{this.contents}}</article>
</li>
{{/each}}
{{else}}
<li>nope</li>
{{/if}}
</ul>
{{/content}}
{{/extend}}
So {{{contents}}}
is a Metalsmith thing, but I understand the rest of your explanation. Thank you for writing that up!
My pleasure! I'm going to close this issue for now, but feel free to reopen it if you're still having trouble.
Hi, I have the following structure:
No matter what though, the built file only outputs
[object Object]
on the page. I'm assuming I'm missing something fairly obvious, so any help would be great!