These are chat archives for jescalan/roots

29th
Jun 2016
Tom Kraak
@tkraak
Jun 29 2016 10:48

@javaporter thx, as always …

do you have tips for retrieving linked fields?

your typical a post has authors, and categories, etc
Dan Woodward
@deedubbleyoo
Jun 29 2016 12:00
Has anyone got any idea how to pass in an external library into the jade templates as a local? Specifically I want to use moment.js to format a date object. There seems to be a lot of answers on how to do this using express, but that doesnt apply to me :(
Tom Kraak
@tkraak
Jun 29 2016 12:14
@deedubbleyoo somebody else was asking about the same thing recently
Dan Woodward
@deedubbleyoo
Jun 29 2016 12:15
thanks @tkraak trying to find the comments now
ok I found an example, and realised I tried that already without success :(
Tom Kraak
@tkraak
Jun 29 2016 12:44
@deedubbleyoo you have a repo we can look at?
Dan Woodward
@deedubbleyoo
Jun 29 2016 12:45
not really at the moment, I think I'll revisit this later once I have everything in place simply - I get bogged down in technicalities too often!
Tom Kraak
@tkraak
Jun 29 2016 12:50
@deedubbleyoo … that sounds very familiar … same here! :)
Tom Kraak
@tkraak
Jun 29 2016 13:45

@deedubbleyoo looks like the androidhub team uses moment or at least tried to:

https://github.com/intel-android/androidhub/blob/master/app.coffee

it’s commented out in their layouts though

that’s a great all around repo to learn from, wish there were more public ones like it
Perry Kibler
@javaporter
Jun 29 2016 13:48

@tkraak this is the std link to post format: a(href= post._url), I haven't had to link to authors or categories yet, but that sounds like a common use. I don't know how off the top of my head, it actually sounds like it might be fairly complex (but it's probably not).

The documentation for this stuff is pretty bare-bones, I've been debating about setting up a public repo where there are examples of how to do things like what you're asking.

Tom Kraak
@tkraak
Jun 29 2016 13:50
@javaporter we definitely need that repo and I would love to collaborate on that
maybe we should also have a dedicated roots-contentful room … let’s see what @jescalan thinks about that

the linked content issue has come up in an issue too:

carrot/roots-contentful#19

just no answers yet :)
Jeff Escalante
@jescalan
Jun 29 2016 13:56
Hi guys!
David Eglin
@djeglin
Jun 29 2016 13:56
Yo!
Tom Kraak
@tkraak
Jun 29 2016 13:56
good morning!
Jeff Escalante
@jescalan
Jun 29 2016 13:56
@deedubbleyoo - npm install moment, require it in your app.js, add it to the locals object, use != to call it as a function in your jade templates
@javaporter happy to review any PRs to boost documentation for roots-contentful, or if you prefer a separate repo to link that up in the readme
@tkraak separate roots-contentful room is :+1:, I'll make the room now
Tom Kraak
@tkraak
Jun 29 2016 13:57
:clap:
Jeff Escalante
@jescalan
Jun 29 2016 13:57
also fyi, we will be moving roots into static-dev
David Eglin
@djeglin
Jun 29 2016 13:57
Have another question about the inner workings of the dynamic-content addon: Is it possible to have a views folder that only holds template files (not rendered in and of itself) and then to have the entire site (home page and all) compiled from another folder using the dynamic-content addon? I just tried moving a couple of things around and it didn't seem to like it
basically I'm trying to do a similar thing as the client-templates addon, but it looks like as I'm using dynamic-content as well, there is a bit of a disconnect between the two and I need to choose one or the other
My head says it makes more sense to have my views/ folder be entirely template logic stuff and build everything with Yaml frontmatter and have it dynamically generated. That would then allow me to have a big json file with every page of the site in it which I could use for some speedy rendering
Perry Kibler
@javaporter
Jun 29 2016 14:00
@jescalan it would make sense to keep it all in the same place, I'll start just adding to contentful-roots
David Eglin
@djeglin
Jun 29 2016 14:01
at the moment, though, it seems like if I don't have an index.jade file inviews/ and I try to do it the other way, the index doesn't get rendered out at all :S (and the json output is either an empty object or undefined)
Jeff Escalante
@jescalan
Jun 29 2016 14:05
@djeglin so to be clear, what youre trying to do is use dynamic content, but also write all the dynamic content data to a json file?
Perry Kibler
@javaporter
Jun 29 2016 14:11
@jescalan do you see what I'm doing wrong here? You can probably guess where I'm headed, but I'm just trying to sort the fields alphabetically by title: - for post in contentful.featuredStories.order='fields.title'
David Eglin
@djeglin
Jun 29 2016 14:23
@jescalan Yes, but for the whole site, rather than just a particular subset of pages
Jeff Escalante
@jescalan
Jun 29 2016 14:24
@javaporter thats invalid syntax if im not mistaken?
@djeglin what data are you trying to extract from the whole site? the entire contents or each page?
Perry Kibler
@javaporter
Jun 29 2016 14:26
@jescalan sure is : ) I just don't the correct syntax
Jeff Escalante
@jescalan
Jun 29 2016 14:32
use a js sort function
for post in sortBy(contentful.whatever, 'title')
then make a sortBy local in app.coffee which uses Array.sort to do what you want
there's no magic jade intelligent sorting functions, unfortunately
you gotta write it yourself
David Eglin
@djeglin
Jun 29 2016 14:35
@jescalan Yeah. I was originally going to use the client-templates addon, but I couldn't work out how that worked with dynamic-content
Jeff Escalante
@jescalan
Jun 29 2016 14:35
ok so your goal is to take the entirety of your site and crate a json object, key is the path to the page, value is the entire page's contents
and write that as a json file?
David Eglin
@djeglin
Jun 29 2016 14:37
yeah. If I could have it include the other frontmatter as items too that would be awesome
Jeff Escalante
@jescalan
Jun 29 2016 14:38
i think you would need to write an extension in order to do this
Perry Kibler
@javaporter
Jun 29 2016 14:38
thanks @jescalan that puts me on the right path
Jeff Escalante
@jescalan
Jun 29 2016 14:38
@javaporter yw! happy to review or help with the function if you've written it
@djeglin this is a huge chunk of customized functionality, spanning across multiple extensions, which means you'll need to write something custom to handle it
what is your intended end use for this?
js-based page renders, by any chance?
David Eglin
@djeglin
Jun 29 2016 14:39
@jescalan Indeed :)
Jeff Escalante
@jescalan
Jun 29 2016 14:39
we are building this as a specific plugin for spike, if that makes any difference
David Eglin
@djeglin
Jun 29 2016 14:45
Interesting... I hadn't looked at Spike before. Whilst I admit I would be sad to give up coffeescript, I realise that ES2015 is the way forward for most people and it makes sense to move in that direction.
Does the pushstate plugin allow for adding in transitions rather than just a javascript version of a hard load?
Jeff Escalante
@jescalan
Jun 29 2016 16:06
no
id consider a pr for this though
but the advantage is that its immediate
like not even a load. you click and it's there
its actually quite an impressive effect on its own haha
Daniel Box
@dbox
Jun 29 2016 17:40
@djeglin This has some of those features: https://github.com/miguel-perez/smoothState.js
but we've never had a smooth implmentation tbh
David Eglin
@djeglin
Jun 29 2016 22:17
@dbox Yeah... Have seen that before but, sadly, it is a jQuery plugin, and I'm really not a jQuery fan. Would sooner write a bit more core JS and/or use some microlibraries than jq.