There are occasions where it is useful to have `target='_blank'` on hyperlinks within your own app. (For example, if your app is being loaded in an iframe and you'd like for the links to break out in to new windows.)
With this PR, the `onClick` logic in Link now checks for an external target on the nested <a/> tag, and will fall back to the default behavior if it's present, similar to the logic for shift-/cmd-clicking the link.
When clicking a next/link with a hash (#something) multiple times, it wouldn't keep the scrolling behavior browsers have. This makes sure we correctly trigger it.
resolves#4115
For now, I just added `'article:tag'` so it could be duplicated if we need more we have to extend:
```javascript
const ALLOWED_DUPLICATES = ['article:tag']
```
Allow `onClick` on `next/link` child. This should not be a breaking change, but it's a very useful feature. Real-life use cases include: analytics or closing menu on navigation, and other.
- [x] allow optional `onClick` on `next/link` component's child
- [x] call original `child.props.onClick(e)` before `this.linkClicked(e)`
- [x] add integration tests
- [x] cancel the navigation if `e.defaultPrevented === true`
Fixes#1490
* Don’t use chunkhash in development
* Add test for dynamic imports styling
* Remove pre-load of dynamic page
* Make sure the browser gets closed only once
* Handle production errors correctly
* Improved source map support
* Make react-hot-loader hold state again
* Remove console.log
* Load modules on demand
* Catch errors in rewriteErrorTrace
* Update comment
* Update comment
* Remove source-map-support
* Load modules in next-dev
* Make sure error logged has sourcemaps too
* Add tests for production runtime errors
* Add tests for development runtime errors. Fix issue with client side errors in development
* Move functionality back to renderError now that error handling is consistent
* Rename to applySourcemaps
* Add specific test cases for Error Recovery.
* Update hmr/about.js
* Add a test case: should recover after a bad return from the render function
* Add test case: should recover from errors in getInitialProps in client
* Add test case: should recover after an error reported via SSR
* Add a test case: should recover from 404 after a page has been added
* Refactor code base.
* Fix SSR error handling.
* Remove unwanted console.logs
* Fix a typo.
* Fix current tests.
* Add a new test case for this case.
* Error should only be logged if it is not a 404
* Add custom-server-typescript example (see #3694)
* Fix linting errors in custom-server-typescript
* Provide proper arguments to ts-node.
* Fix import and fix all linting errors.
* Use import in server as well.
* Update nodemon.json
* Allow next/asset to work properly with dynamic assetPrefix
Now we use webpack's publicPath via client side.
* Add test cases for dynamic assetPrefix and next/asset.
* Add .jsx extension
* examples: add create-next-app (#3377)
* examples: add create-next-app
* fix with-typescript readme
* Upgrading with-flow example to the latest flow-bin ver. 0.59.0 (#3337)
For upgrading I used flow-upgrade module by https://yarnpkg.com/en/package/flow-upgrade
* doc'd fs-routing option & added note on `passHref` (#3384)
2 changes:
`passHref` - just added a cautionary note on the importance of `passHref`. We had a few days of no-href links on our site b/c we used a custom component instead of a raw `<a>` tag, and Google bot wasn't crawling our links (confirmed in Google cache). Hurt our SEO a bit, so I thought it was worth noting.
`useFileSystemPublicRoutes` - this is mentioned in https://github.com/zeit/next.js/pull/914 , but it doesn't appear any doc was actually added. We use `next-routes`, and we were serving all the files in `/pages/` in addition to their route patterns (ie duplicate content), which can be a pain w/ SEO and duplicate content.
* fix typo in readme.md (#3385)
* Upgrade styled-jsx to v2.2.1 (#3358)
* Pulled encoding to top of head (#3214)
* Remove next.d.ts to use @types/next (#3297)
* Add with-mobx-state-tree example (#3179)
* Adapt with-mobx example for with-mobx-state-tree
* Remove unnecessary lastUpdate parameter to show off snapshot
* update readme
* make other.js more closely mimic index.js
* Upgrade styled-jsx to v2.2.1
Includes some bug fixes.
* Fix linting
* Make sure import that doesn’t end in .jsx works
* Move tests
* Show error when .js and .jsx both exist
* Remove .jsx when importing from ‘path.jsx’
* Fixes
* Get .jsx resolver back
* Revert "Get .jsx resolver back"
This reverts commit 6f76712caa400e6f41a6a32ff80189a95b194cce.
* Revert "Revert "Get .jsx resolver back""
This reverts commit 69e592e86e53f28d0e1f78009196b76f2f831866.
* Add remove .jsx to preset
* Remove jsx resolver
* Revert "Remove jsx resolver"
This reverts commit 5e3ef1aca134de47657d91485809cd801e13329f.
* Revert "Revert "Remove jsx resolver""
This reverts commit 8248e5066cff1c7e33dac2e5a88ffe6856e3fc4e.
* Revert "Revert "Revert "Remove jsx resolver"""
This reverts commit 2a6d418a227ea4e59874b0374628ef497e527c52.
* Make 1 component not use .jsx
* Support de-deduping head tags by setting key
* move dedupe logic to `unique` function
* fix head tag deduping logic
* remove console.log
* use `toContain` assertions
* update de-duping head tags section in README
* Add withRoute HOC
Rebased (squashed)
- removed routerToProps
- updated hoist-non-react-statics
- improved propTypes
* Expose the whole Router instead of the route.
* Make the example simple.
* Update examples and the readme.
* Add a test case.
* Layout ground works for next/async
* Implement the Dynamic Bundle feature.
* Add some test cases.
* Update README.
* Implement props aware dynamic bundle API.
* Update tests and README.
* Add a test case for React Context support.
* Always check with the fs when gettings chunks.
* Add a new set of test cases for dynamic imports in dev.
* Add dynamic import test cases for production.
* Add availableChunks support for static exports.
* Reload webpack via hot-reloader when needed.
We need to do this specially we removed a previosly
built page from the filesystem.
* Make sure reloading is happen only once
* Reload only if there's a missing page error.
* Remove debug logs.
* 2.4.2
* Refactor the codebase a bit.
* Move some commonly used regexp to a utils module.
* Handle the reloading well when there's a custom error page.
* Add a HMR test case.
* Close the browser in the test case.
* Fix HMR not working issue.
Our hot-reload code on the server has custom webpack error dectection logic.
Is supports only multi-modules entries.
So, we need to all entries as multi-module entries
even if there's just a single entry.
* Add a test case for showing errors over HMR.
* Using developit/unfetch as the Fetch API polyfill
* Added the replace prop into the Link component
* Added integration test for replace prop on Link component
* Add support for URL objects in Link and Router
* Fix typo in comment
* Fix possible bug if the `href` prop is `null`
* Document the usage of URL objects in Link and Router
* Update readme.md
* Parse URL to get the host & hostname in `isLocal`
This should check if the current location and the checked URL have the same `host` or `hostname`.
* Format `as` parameter from object to string if required
* Format `href` and `as` inside the construct and componentWillReceiveProps
* Use `JSON.stringify` to compare objects
* Add usage example
* chore(package): update chromedriver to version 2.28.0 (#1386)
https://greenkeeper.io/
* Refactor the codebase a bit.
* Change the example name.
* Add a few test cases.
* Add the example to the README.
* Simplify route info handling.
* Add basic resolve=false support.
* Make sure to render getInitialProps always if it's the first render.
* Change resolve=false to shallow routing.
* Add test cases for shallow routing.
* Update README for shallow routing docs.
* Update docs.
* Update docs.
* Update docs.
* Add better hash URL support.
1. Add scrolling to given id related to hash
2. Hash changes won't trigger getInitialProps
* Add some comments.
* Fix tests.
* Add some test cases.
* Remove traces of glamor
As talked about with @rauchg. Glamor takes up around 60KB of the bundle (pre-gzip). Since styled-jsx is the way to go now and we support adding glamor by the user we should remove it as dependency cause it is bundled even when not used.
Added rehydration to the example, since we did that in our code.
There is only one thing I'm not sure about and want to discuss:
what should we do with next/css. Right now I added a throw for when it is imported. I'm not sure if we should do that / some other way to notify the user it has been removed. The reasoning behind the throw is that when we would do a console.warn the user would see 'css.default.<X>' not found because we don't have the glamor dependency anymore.
* Update yarn.lock
* Remove test for styles
* Add support to reload the page when ask to change the same url.
* Do not run change() in the initial page load.
* Add integration tests.
* Add self-reload.js
* Make sure lastAppProps always have some value.
* Revert "Make sure lastAppProps always have some value."
This reverts commit b4ae722d9c1a4460e17dbdc041b111cbd492b2aa.
* Throw an error, if we found an empty object from getInitialProps.
* Add proper tests for getInitialProps empty check.