小编Mat*_*ous的帖子

Hot Towel:为什么Durandal和Require在App文件夹而不是Script文件夹中?

这来自第三方库在Script中的想法,以阻止开发人员自定义它们.它会鼓励他们编写扩展,以便更容易地接受任一库的新版本.

requirejs single-page-application durandal hottowel

5
推荐指数
1
解决办法
1363
查看次数

主题开发:添加自定义句柄栏助手

对于techno主题,我想让用户可以使用自定义hb帮助程序和配置.为此,我将覆盖应用于[ghost root] /index.js.

下面的代码在当前主题文件夹中搜索index.js并运行它.

var ghost = require('./core'),
    errors = require('./core/server/errorHandling');

ghost()
.then(function (param) {

    var settings = require('./core/server/api').settings;

    settings
        .read({key: 'activeTheme', context: {internal: true}})
        .then(function (result) {

            try {
                require('./content/themes/' + result.value + '/index')();
            }
            catch (e) {
                //No custom index found, or it wasn't a proper module.
            }

        });
})
.otherwise(function (err) {
    errors.logErrorAndExit(err, err.context, err.help);
});
Run Code Online (Sandbox Code Playgroud)

主题级别index.js注入自定义博客变量(来自配置文件)和hb帮助程序.

var hbs = require('express-hbs'),
    _ = require('lodash'),
    downsize = require('downsize'),
    blogVariable = require('../../../core/server/config/theme');

module.exports = function() {

    //This …
Run Code Online (Sandbox Code Playgroud)

ghost-blog

3
推荐指数
1
解决办法
1762
查看次数