hapi-mobile-views

2.0.0 • Public • Published

hapi-mobile-views

Build Status Coverage Status

Detects mobile user agents and serves mobile views when available.

Install

npm install hapi-mobile-views

Usage

Basic:

// index.js
server.register(require('hapi-mobile-views'));

Rapptor:

# default.yaml 
plugins:
  hapi-mobile-views:

Serving mobile views

NOTE: Currently only *.html view files are supported and we're only testing against the vision module.

This plugin handles everything except creating the mobile views for you. In order to service up a mobile view you will need to create a file that matches a view but end with -mobile in the name.

If your return looks like and the template was pages/homepage.html

reply('pages/homepage');

You'd name the mobile version pages/homepage-mobile.html

We also expose a global view context __isMobile. Useful if you don't need to change the whole page, just a part. (You should still use media queries if you can).

Manual Override

Direct the user to the same url but with a ftDeviceType=<type> query string. Valid types are mobile and desktop. The user will be redirected to the original url with a cookie set with the device type.

Readme

Keywords

Package Sidebar

Install

npm i hapi-mobile-views

Weekly Downloads

1

Version

2.0.0

License

UNLICENSED

Unpacked Size

9.95 kB

Total Files

5

Last publish

Collaborators

  • jga
  • dawnerd
  • ecwillis
  • orthagonal1
  • alaguna
  • aleperez92