在公共场合/使用MeteorJS和铁路由器时提供"index.html"文件?

goz*_*ike 6 meteor iron-router

我想从MeteorJS的公共文件夹中提供静态HTML文件(可以使用Rails和Express).我这样做的原因是因为我有一个模板用于我的webapp的动态"admin"部分,另一个模板用于app的sales-y"frontend"部分.

我不希望这个文件被包装在Meteor模板中,如本答案所示,因为它会自动引入动态页面使用的缩小的CSS等.

有没有办法我可以设置公用文件夹(及其所有子文件夹),以便它为index.html服务?这样http://app.com/将加载public/index.html?

Rah*_*hul 8

您可以使用该private文件夹,然后使用Assets.getText加载文件的内容,然后使用来自铁路由器的服务器端路由器进行服务.

所以在我的头顶,代码看起来像这样:

if (Meteor.isServer) {
  Router.map(function() {
    this.route('serverRoute', {
      path: '/',
      where: 'server',
      action: function() {
        var contents = Assets.getText('index.html');
        this.response.end(contents);
      }
    });
  });
}
Run Code Online (Sandbox Code Playgroud)