如何在 Meteor 中使用 Prerenderio? [英] How to use Prerenderio with Meteor?

查看:37
本文介绍了如何在 Meteor 中使用 Prerenderio?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在带有模数的服务器上使用带有 Meteor 的 prerenderio 而不是 phantomjs.

I would like to use prerenderio with Meteor instead of phantomjs on the server with modulus.

但是鉴于他们提供的示例,我不确定如何集成它.他们只提供一个 node express 中间件,不能 100% 翻译.

However given the examples they provide, I'm not sure how to integrate it. They only provide a node express middleware which doesn't translate 100%.

推荐答案

为了 SEO 目的?我的意思是,还能是什么?;)

For SEO purposes? I mean, what else could it be? ;)

首先,如果您还没有删除可蜘蛛包.

Firstly, remove the spiderable package if you haven't already.

其次,将其放在您的服务器端代码中(例如 server/prerenderio.js):

Second, drop this at your server-side code (for example server/prerenderio.js):

// Use Prerender with your token
var prerenderio = Npm.require('prerender-node').set('prerenderToken', 'YOUR_TOKEN'); 
// Feed it to middleware! (app.use)
WebApp.connectHandlers.use(prerenderio);

如果你想知道 Npm.require(或 Meteor.require),请看这个答案(由我,对不起无耻的插件)的要点:https://stackoverflow.com/a/16481897/951773

If you're wondering about Npm.require (or Meteor.require), See this answer (by me, sorry for shameless plug) for the gist: https://stackoverflow.com/a/16481897/951773

来源:我已经成功地为我们的几个客户使用了 prerenderio.

Source: I've used prerenderio successfully for a couple of our clients.

![祝你好运!][1]

![Good luck!][1]

由于现在对meteor 的连接对象的快速请求和响应对象之间存在重大差异,因此现在变得非常复杂.但是现在已经解决了这个问题,希望我投入的公关工作:

Since there has been major differences now between express request and response objects to meteor's connect objects, it went to really complicated now. But this has been addressed now and hopefully the PR I put in works:

https://github.com/dfischer/meteor-prerenderio/issues/1

TL;DR 感谢这个问题,现在我们有了 prerender.io 流星模块.

TL;DR Thanks to this question now we have a prerender.io meteor module.

这篇关于如何在 Meteor 中使用 Prerenderio?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆