-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
237 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
const withPreact = require('@zeit/next-preact') | ||
module.exports = { | ||
webpack: function (config) { | ||
config.resolve.alias = { | ||
...config.resolve.alias, | ||
react: 'preact/compat', | ||
react$: 'preact/compat', | ||
'react-dom': 'preact/compat', | ||
'react-dom$': 'preact/compat' | ||
} | ||
|
||
module.exports = withPreact() | ||
return config | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
import React from 'react' | ||
import ReactDOMServer from 'react-dom/server' | ||
|
||
export default function Noscript (props) { | ||
const staticMarkup = ReactDOMServer.renderToStaticMarkup(props.children) | ||
// We don't want to send 'react-dom/server' to the client | ||
let ReactDOMServer | ||
if (typeof window === 'undefined') { | ||
ReactDOMServer = require('react-dom/server') | ||
} | ||
|
||
export default function Noscript ({ children }) { | ||
if (!ReactDOMServer) { | ||
return null | ||
} | ||
const staticMarkup = ReactDOMServer.renderToStaticMarkup(children) | ||
return <noscript dangerouslySetInnerHTML={{ __html: staticMarkup }} /> | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,15 @@ | ||
import React from 'react' | ||
import LazyLoad from 'react-lazyload' | ||
import Noscript from '../components/Noscript' | ||
|
||
const images = [ | ||
'/static/img/reactjs.png', | ||
'/static/img/nextjs.png', | ||
'/static/img/vuejs.png', | ||
'/static/img/angular.jpg' | ||
] | ||
export default function IndexPage () { | ||
return ( | ||
<> | ||
<h1>noscript</h1> | ||
<p>Disable JavaScript to see it in action:</p> | ||
|
||
class Index extends React.Component { | ||
static getInitialProps (context) { | ||
const { isServer } = context | ||
return { isServer } | ||
} | ||
render () { | ||
return ( | ||
<div style={{ textAlign: 'center' }}> | ||
{images.map((item, index) => ( | ||
<div key={index}> | ||
<LazyLoad height={700} offset={100}> | ||
<img width={700} height={700} src={item} alt={`image_${index}`} /> | ||
</LazyLoad> | ||
<Noscript> | ||
<img width={700} height={700} src={item} alt={`image_${index}`} /> | ||
</Noscript> | ||
</div> | ||
))} | ||
</div> | ||
) | ||
} | ||
} | ||
<hr /> | ||
|
||
export default Index | ||
<Noscript>Noscript is enabled!</Noscript> | ||
</> | ||
) | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,5 @@ | |
"registry": "https://registry.npmjs.org/" | ||
} | ||
}, | ||
"version": "9.1.2-canary.2" | ||
"version": "9.1.2-canary.3" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.