【问题标题】:Tell GULP to use different layout files for different domain paths告诉 GULP 为不同的域路径使用不同的布局文件
【发布时间】:2020-12-06 03:13:47
【问题描述】:

在我的 node.js 服务器上使用此代码

// Copy page templates into finished HTML files
function pages() {
  return gulp.src('src/pages/**/*.{html,hbs,handlebars}')
    .pipe(panini({
      root: 'src/pages/',
      layouts: 'src/layouts/',
      partials: 'src/partials/',
      data: 'src/data/',
      helpers: 'src/helpers/'
    }))
    .pipe(gulp.dest(PATHS.dist));
}

它适用于页面 - 其中 f.e. src/pages/DE 中的 start.html 用于 mydomain.de/DE/start.html,src/pages/EN 中的 start.html 用于 mydomain.de/EN/start.html

但是对于我需要指定语言等内容的布局,这将不起作用。 还有两个文件夹 - src/layouts/DE 和 src/layouts/EN 都包含一个 default.html 文件。 但无论我选择哪个域路径,构建系统总是使用 EN 路径中的文件。 有什么建议吗?

【问题讨论】:

    标签: node.js gulp


    【解决方案1】:

    下面做的工作

    // Copy page templates into finished HTML files
    function pages() {
      return gulp.src('src/pages/**/*.{html,hbs,handlebars}')
        .pipe(panini({
          root: 'src/pages/',
          layouts: 'src/layouts/',
          partials: 'src/partials/',
          data: 'src/data/',
          helpers: 'src/helpers/',
          pageLayouts: {
            'DE': 'DE',
            'EN': 'EN',
      }
        }))
        .pipe(gulp.dest(PATHS.dist));
    }
    

    只需添加 pageLayouts,这意味着 src/pages/DE 中的所有页面都应该使用 FILE !!! src/layouts/DE.html - 与 EN 相同。布局中不需要子文件夹。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多