流星厨房服务器端渲染

时间:2016-09-01 05:07:31

标签: meteor

有没有办法让meteor-kitchen在服务器端渲染?

目前它通过javascript渲染所有内容,但我还计划构建REST API,因此我需要服务器端渲染。

1 个答案:

答案 0 :(得分:0)

您可以使用meteorhacks完成服务器端渲染:ssr + iron:router。您在服务器端创建铁路线,然后渲染火焰模板。这是一个示例路线。

this.route('home', {
    where: 'server,
    path: '/',
    action: function() {
        var templateData = {};
        var html = SSR.render('templateName', templateData);
        this.response.writeHead(200, {'Content-Type': 'text/html'});
        this.response.write(html);
        this.response.end();
    }
}); 

我使用此方法为https://gameraven.com/上的SEO提供静态页面。