These are chat archives for jescalan/roots

12th
Sep 2015
Michael Kornblum
@michaelkornblum
Sep 12 2015 02:11
Hello all, I'm having a bit of difficulty getting links to render in my project, namely in the portion of the page that is used to render a blog archive in the sidebar. Has anyone here had any experience working with moment.js, and lodash with the dynamic contents plugin?
Michael Kornblum
@michaelkornblum
Sep 12 2015 02:17
The archive section of the template looks like this
+- var posts = _.sortBy(site.posts.blog, 'date').reverse()
+- var latestPost = posts[0]
+- var latestPostDate = moment(latestPost.date)
+- var latestPostYear = latestPostDate.year()
+- var latestPostMonth = latestPostDate.month()
+- var latestPostDay = latestPostDate.date()
+h2 Archives 
+h3=latestPostDate.format('MMMM YYYY')
+<ul>
+for post in posts
+  - var currentPostDate = moment(post.date)
+  - var currentPostYear = currentPostDate.year()
+  - var currentPostMonth = currentPostDate.month()
+  - var currentPostDay = currentPostDate.date()
+  
+  if (currentPostMonth < latestPostMonth || currentPostYear < latestPostYear)
+    - currentPostMonth = latestPostMonth
+    - currentPostYear = latestPostYear
+    </ul>
+    h3=currentPostDate.format("MMMM YYYY")
+    <ul>
+  li #[a(href=post._url)=moment(post.date).format("MMMM DD, YYYY") + ": " + post.title]
+</ul>
It works reasonably well, until I click one of the links, at which point entries start disappearing.
A similar issue manifests with the latest post section of the sidebar:
+h2 Latest Posts
+- var posts = _.sortBy(site.posts.blog, 'date').reverse()
+- var i = 0
+- var postIndex = posts.length
+if postIndex > 5
+  - postIndex = 5  
+ul
+  while i < postIndex
+    li #[a(posts[i]._url)=moment(posts[i].date).format('MMMM, DD YYYY') + ': ' + posts[i].title]
+    - i++
If anyone could help me, I'd really appreciate it.
Dominic Monroe
@SevereOverfl0w
Sep 12 2015 23:02
@michaelkornblum Disappearing?! from where?
The DOM?