How to configure multi-language site in gruntfile.js?

送分小仙女□ 提交于 2019-12-25 02:26:21

问题


I have a problem that every time I run grunt assemble in the terminal, the task will never complete. Here is my assemble task in gruntfile.js, can someone please tell me if there are anything wrong with it?

   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 %>/'
                }
            ]
        }
    },

I used grunt assemble --verbose and it outputs the following messages:

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

But when I look into my .tmp folder, there is no .tmp/en/product.html file.

来源:https://stackoverflow.com/questions/24498069/how-to-configure-multi-language-site-in-gruntfile-js

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!