These are chat archives for jescalan/roots

15th
Jul 2016
Eleazar Junsan
@eljun
Jul 15 2016 08:56

Hello @jescalan, I've done the direction you specified on the dynamic-content documentation for adding single_posts_views using jade, but it does not work.

Can you verify this to your end if it is fully working? Thanks

David Eglin
@djeglin
Jul 15 2016 10:06
Hi @eljun it's definitely working as I'm using it at the moment...
So, in each of your posts, you will need to have an extends statement that points to a jade template that will be used to render the post

so for me, the top each of my posts looks a bit like this:

---
title: "Article title"
description: "Article description"
date: 30/4/2016
heroImage: "article-hero.jpg"
heroAlt: "Hero alt text"
---

extends /views/shared/post

block postContent

Obviously some of that frontmatter isn't relevant to you, but you can see the extends statement there pointing to a template jade file

and then a block statement which corresponds to a block in the template file
David Eglin
@djeglin
Jul 15 2016 10:16

(it's worth noting that to reference templates etc with root-relative paths like I have, you will need to set a basedir local in your app.coffee... I have mine set up like this:

locals: 
    marked: marked
    slug: slug
    _: require 'lodash'
    moment: require 'moment'
    basedir: __dirname

In that example, __dirname is a pointer to the root of your roots project. Doing that simply exposes it to your templates so you don't have to deal with moving up folder levels to get to things

Tom Kraak
@tkraak
Jul 15 2016 10:51
@djeglin thx for sharing ... I learned a thing or 2 from this!
David Eglin
@djeglin
Jul 15 2016 10:52
@tkraak No worries... That's what a community is for :)
Tom Kraak
@tkraak
Jul 15 2016 10:58
:+1: