0
我只改變了幾頁,但docpad似乎再次呈現一切。我沒有使用任何花哨的插件或動態組件 - 只是基本的鬼模板。有沒有一些技術可以減少頁面渲染?如何加快docpad渲染速度?
也許它與docpad.coffee中的時間戳格式有關?
moment = require('moment')
docpadConfig = {
templateData:
vars:
appserver: 'http://xxx'
site:
title: 'Pocket Tutor'
tagline: 'English language chat tutor'
description: 'Learn english by chatting'
logo: '/uploads/images/corpid/comiceng/96/logo-96.png'
url: 'http://app:9005'
cover: '/img/cover.jpg'
navigation: [
{
name: 'Home',
href: '/',
section: 'home'
},
{
name: 'About',
href: '/about.html',
section: 'about'
},
{
name: 'Lessons',
href: '/tags/lessons.html',
section: 'tag-lessons'
},
{
name: 'Grammar',
href: '/tags/grammar.html',
section: 'tag-grammar'
}
{
name: 'Teachers',
href: '/tags/tech.html',
section: 'tag-tech'
},
]
author:
name: 'Rikai Labs'
img: ''
url: 'http://rikai.co'
website: 'http://RIKAI.co'
location: 'space',
bio: 'we build chat apps'
getPreparedTitle: -> if @document.title then "#{@document.title} | #{@site.title}" else @site.title
getDescription: -> if @document.description then "#{@document.description} | #{@site.description}" else @site.description
bodyClass: -> if @document.isPost then "post-template" else "home-template"
masthead: (d) ->
d = d || @document
if d.cover then d.cover else @site.cover
isCurrent: (l) ->
if @document.section is l.section then ' nav-current'
else if @document.url is l.href then ' nav-current'
else ''
excerpt: (p,w) ->
w = w || 26
if p.excerpt then p.excerpt else p.content.replace(/<%.+%>/gi, '').split(' ').slice(0, w).join(' ')
encode: (s) -> encodeURIComponent(s)
slug: (s) -> return s.toLowerCase().replace(' ', '-')
currentYear: -> new Date().getFullYear()
time: (ts, format) ->
format = format || 'MMMM DO, YYYY'
ts = new Date(ts) || new Date()
moment(ts).format(format)
collections:
posts: ->
@getCollection("html").findAllLive({active:true, isPost: true, isPagedAuto: {$ne: true}}, {postDate: -1}).on "add", (model) ->
model.setMetaDefaults({layout:"post"})
plugins:
tags:
extension: '.html'
injectDocumentHelper: (doc) ->
doc.setMeta { layout: 'tag' }
rss:
default:
collection: 'posts'
url: '/rss.xml'
marked:
gfm: true
environments: # default
development: # default
# Always refresh from server
maxAge: false # default
# Only do these if we are running standalone via the `docpad` executable
checkVersion: process.argv.length >= 2 and /docpad$/.test(process.argv[1]) # default
welcome: process.argv.length >= 2 and /docpad$/.test(process.argv[1]) # default
prompts: process.argv.length >= 2 and /docpad$/.test(process.argv[1]) # default
# Listen to port 9005 on the development environment
port: 9005 # example
production:
port: 9005
maxAge: false # default
}
module.exports = docpadConfig
更新:刪空的日期和時間的方法
time: -> 'time'
currentYear: -> 'year'
給人有點加快,但仍使一個編輯一個文件給出信息:
Generated 40/150 files in 7.364 seconds
UPDATE2:添加
standalone: true
以某些頁面來測試,但仍然需要 info:在7.252秒內生成40/150個文件
因此即使是一個單獨的頁面也會觸發一堆其他內容。