How to use Prerenderio with Meteor?

喜欢而已 提交于 2019-12-07 02:26:48

问题


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

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%.


回答1:


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

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

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);

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

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

![Good luck!][1]

EDIT:

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 Thanks to this question now we have a prerender.io meteor module.



来源:https://stackoverflow.com/questions/26322771/how-to-use-prerenderio-with-meteor

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