From d626629144fd488e1928e324383bf2197e92a191 Mon Sep 17 00:00:00 2001 From: tim neutkens Date: Fri, 3 Mar 2017 23:03:11 +0100 Subject: [PATCH] Add with-ie11 example --- examples/with-ie11/README.md | 28 +++++++++++++++++++++++++++ examples/with-ie11/package.json | 17 ++++++++++++++++ examples/with-ie11/pages/_document.js | 28 +++++++++++++++++++++++++++ examples/with-ie11/pages/index.js | 22 +++++++++++++++++++++ examples/with-ie11/pages/preact.js | 22 +++++++++++++++++++++ 5 files changed, 117 insertions(+) create mode 100644 examples/with-ie11/README.md create mode 100644 examples/with-ie11/package.json create mode 100644 examples/with-ie11/pages/_document.js create mode 100644 examples/with-ie11/pages/index.js create mode 100644 examples/with-ie11/pages/preact.js diff --git a/examples/with-ie11/README.md b/examples/with-ie11/README.md new file mode 100644 index 000000000000..9a29724082ac --- /dev/null +++ b/examples/with-ie11/README.md @@ -0,0 +1,28 @@ + +# With Internet Explorer 11 example + +## How to use + +Download the example [or clone the repo](https://github.com/zeit/next.js): + +```bash +curl https://codeload.github.com/zeit/next.js/tar.gz/master | tar -xz --strip=2 next.js-master/examples/with-ie11 +cd with-ie11 +``` + +Install it and run: + +```bash +npm install +npm run dev +``` + +Deploy it to the cloud with [now](https://zeit.co/now) ([download](https://zeit.co/download)) + +```bash +now +``` + +## The idea behind the example + +This example shows how to add a `Promise` polyfill to Next.js. Which allows you to use Next.js on Internet Explorer 11. diff --git a/examples/with-ie11/package.json b/examples/with-ie11/package.json new file mode 100644 index 000000000000..4d8f73049dee --- /dev/null +++ b/examples/with-ie11/package.json @@ -0,0 +1,17 @@ +{ + "name": "with-ie11", + "version": "1.0.0", + "scripts": { + "dev": "next", + "build": "next build", + "start": "next start" + }, + "dependencies": { + "isomorphic-fetch": "^2.2.1", + "next": "^2.0.0-beta", + "react": "^15.4.2", + "react-dom": "^15.4.2" + }, + "author": "", + "license": "ISC" +} diff --git a/examples/with-ie11/pages/_document.js b/examples/with-ie11/pages/_document.js new file mode 100644 index 000000000000..ace772029ac8 --- /dev/null +++ b/examples/with-ie11/pages/_document.js @@ -0,0 +1,28 @@ +import Document, { Head, Main, NextScript } from 'next/document' + +export default class MyDocument extends Document { + static async getInitialProps (context) { + const props = await super.getInitialProps(context) + + const userAgent = context.req.headers['user-agent'] + const isIE11 = !!userAgent.match(/Trident\/7\./) + + return { ...props, isIE11 } + } + + render () { + return ( + + + {this.props.isIE11 ? ( +