如何在gruntfile.js中配置多语言站点?

时间:2014-06-30 20:01:30

标签: gruntjs assemble

我遇到一个问题,即每次在终端中运行grunt assemble时,任务都将永远无法完成。这是我在gruntfile.js中的assemble任务,有人可以告诉我它是否有任何问题吗?

   assemble: {
        options: {
            flatten: true,
            assets: '<%= config.tmp %>/assets',
            layout: ['<%= config.src %>/templates/layouts/default.hbs'],
            //data: '<%= config.src %>/data/*.{json,yml}',
            data: ['<%= config.src %>/data/**/*.{json,yml}'],
            partials: ['<%= config.src %>/templates/partials/*.hbs'],
            plugins: ['assemble-contrib-anchors',
                'assemble-contrib-permalinks',
                'assemble-contrib-toc',
                'assemble-contrib-i18n',
                'assemble-contrib-contextual'
            ], //'assemble-contrib-sitemap'
            contextual: {
                dest: '<%= config.tmp %>/'
            },
            i18n: {
                // data: ['<%= config.src %>/data/i18n.json'],
                // templates: ['<%= config.src %>/templates/*.hbs']
                languages: buildLanguages, // buildLanguages = ['en','de','ru']
                templates: ['<%= config.src %>/templates/pages/*.hbs']
            },
            permalinks: {
                structure: ':language/:file:ext'
            },
            files: {
                '<%= config.src %>/': ['<%= config.src %>/templates/pages/*.hbs']
            }
        },
        dist: {
            files: [
                {
                    src: '<%= config.src %>/templates/pages/*.hbs',
                    dest: '<%= config.tmp %>/'
                }
            ]
        }
    },

我使用grunt assemble --verbose并输出以下消息:

Assembling pages...

{ _page: 'all',
  dirname: '.tmp',
  filename: 'products-en.html',
  pageName: 'products-en.html',
  pagename: 'products-en.html',
  basename: 'products-en',
  src: 'src/templates/pages/products-en.hbs',
  dest: '.tmp/en/products.html',
  assets: '../assets',
  ext: '.html',
  extname: '.html',
  page: '\n\n<h1>Products!</h1>',
  data: { language: 'en', file: 'products' },
  filePair: 
   { src: [Getter],
     dest: '.tmp/',
     orig: { src: [Object], dest: '.tmp/' } },
  index: 3,
  number: 4,
  first: false,
  prev: 2,
  middle: true,
  next: 4,
  last: false,
  slug: 'products-en',
  isCurrentPage: false,
  relativeLink: 'products.html' }
Currentpage: [object Object]
Variables loaded

但是当我查看我的.tmp文件夹时,没有.tmp/en/product.html文件。

0 个答案:

没有答案