2.0.0 • Published 7 years ago

hapi-mobile-views v2.0.0

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
7 years ago

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.

2.0.0

7 years ago

1.1.0

9 years ago

1.0.0

9 years ago