do_populate_prev_next

in jekyll/plugins/toc_generator.rb [50:78]


  def do_populate_prev_next(pages, toc, missing_titles)
      p = nil
      toc.each_with_index do |t,i|
          j = i + 1
          n = toc[j] if j < toc.length
          while j < toc.length and not n.nil? and not n.key?(:path) do
              j = j + 1
              n = toc[j]
          end

          if t.key?(:path)
              this_page = pages[t[:path]]

              this_page.data["previous"] = pages[p[:path]] unless p.nil?
              this_page.data["next"] = pages[n[:path]] unless n.nil?

              return if not n.nil? and n[:path].start_with?('http')
              raise "unknown page: #{n.inspect}" if not n.nil? and pages[n[:path]].nil?

              missing_titles << p[:path] if not p.nil? and not pages[p[:path]].data.key?("title")
              missing_titles << n[:path] if not n.nil? and not pages[n[:path]].data.key?("title")

              do_populate_prev_next(pages, t[:pages], missing_titles) if t.key?(:pages)

              p = t
          end
      end
  end