项目作者: obiyuta

项目描述 :
Prerender plugin for creating mobile snapshot
高级语言: JavaScript
项目地址: git://github.com/obiyuta/prerender-mobile-useragent.git
创建时间: 2015-10-07T09:49:10Z
项目社区:https://github.com/obiyuta/prerender-mobile-useragent

开源协议:MIT License

下载


prerender-mobile-useragent npm version

Prerender plugin that enables you to create snapshots that prepared for mobile devices(iPhone, Android…).

How it works

Prerender creates snapshots with PhantomJS useragent (like the following) even if the original request is from mobiles.

  1. PhantomJS/x.x.x ...

If you prepare pages, layouts or styles for mobiles depends on those useragent, you have to request with mobile useragent.

So this plugin adds ‘iPhone’(default) to the Phantom’s useragent when the original request is from mobile devices or bot.

  1. PhantomJS/x.x.x ... iPhone

Requirement

  • Prerender >= 4.0.2

Usage

In your local prerender project run:

  1. $ npm install prerender-mobile-useragent --save

Then in the server.js that initializes the prerender:

  1. server.use(require('prerender-mobile-useragent'));

Using External Configuration

You can use the enviroment variable MOBILE_USER_AGENT

  1. export MOBILE_USER_AGENT=mobile-useragent
  2. # default is 'iPhone'