       tags: entry.tags
       title: entry.title
       titleKey: titleKey
-    paths: [
-      dir + '/' + titleKey + '/index.html'
-      if titleKey is 'diary' then null else dir + '/diary/index.html'
-      dir + '/index.html'
-    ].filter (i) -> i
+    entry
+
+prerenderEntry = (entry) ->
+  dir = moment(entry.pubdate).format 'YYYY/MM/DD'
+  titleKey = entry.titleKey
+  paths = [
+    dir + '/' + titleKey + '/index.html'
+    if titleKey is 'diary' then null else dir + '/diary/index.html'
+    dir + '/index.html'
+  ].filter (i) -> i
+  paths.forEach (path) ->
+    prerender(baseDir + path, entry)
 
 ignoreError = (stream) ->
   stream.on 'error', (e) ->


gulp.task 'build-html', ->
  baseDir = './dist/'
  loadEntriesV3('./data/**/*.md').forEach ({ paths, entry }) ->
    paths.forEach (path) ->
      prerender(baseDir + path, entry)
  prerender(baseDir + 'index.html', null)

gulp.task 'build-html-dev', ->
  baseDir = './dist/'
  loadEntriesV3('./data/nofile.md').forEach ({ paths, entry }) ->
    paths.forEach (path) ->
      prerender(baseDir + path, entry)
  prerender(baseDir + 'index.html', null)

gulp.task 'build-images', ->

  marked = require 'marked'
  site = myjekyll src, {}
  site.entries().map (entry) ->
    titleKey = entry.file.match(/^\d+-\d+-\d+-(.+)$/, '$1')[1]
    entry =
      content: marked entry.content
      date: moment(entry.pubdate).format 'YYYY-MM-DD'
      description: entry.content.substring(0, 100)
      file: entry.file
      minutes: entry.minutes
