UNPKG

4.39 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _extends2 = require('babel-runtime/helpers/extends');
8
9var _extends3 = _interopRequireDefault(_extends2);
10
11var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
12
13var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
14
15var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
16
17var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
18
19var _createClass2 = require('babel-runtime/helpers/createClass');
20
21var _createClass3 = _interopRequireDefault(_createClass2);
22
23var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
24
25var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
26
27var _inherits2 = require('babel-runtime/helpers/inherits');
28
29var _inherits3 = _interopRequireDefault(_inherits2);
30
31var _react = require('react');
32
33var _react2 = _interopRequireDefault(_react);
34
35var _reactRouter = require('react-router');
36
37var _CollectionContext = require('./CollectionContext');
38
39function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40
41var CollectionPageLink = function (_React$Component) {
42 (0, _inherits3.default)(CollectionPageLink, _React$Component);
43
44 function CollectionPageLink() {
45 (0, _classCallCheck3.default)(this, CollectionPageLink);
46 return (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(CollectionPageLink).apply(this, arguments));
47 }
48
49 (0, _createClass3.default)(CollectionPageLink, [{
50 key: 'render',
51 value: function render() {
52 var toPage = this.props.toPage;
53 var page = this.context.page;
54
55 var nextPageNumber = page.collection.pageNumber + toPage;
56 if (nextPageNumber < 1 || nextPageNumber > page.collection.pageCount) {
57 return null;
58 }
59 var to = nextPageNumber === 1 ? page.createPath() : page.createPath('@page', nextPageNumber);
60 return _react2.default.createElement(_reactRouter.Link, (0, _extends3.default)({}, this.props, { to: to }));
61 }
62 }]);
63 return CollectionPageLink;
64}(_react2.default.Component); /**
65 * @copyright 2016-present, Sitegen team
66 */
67
68CollectionPageLink.defaultProps = {
69 toPage: 1
70};
71CollectionPageLink.contextTypes = _CollectionContext.contextTypes;
72exports.default = CollectionPageLink;
73//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9Vc2Vycy9hbmRyZXlwb3BwL1dvcmtzcGFjZS9zaXRlZ2VuL3NyYy9Db2xsZWN0aW9uUGFnZUxpbmsuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBSUE7Ozs7QUFDQTs7QUFDQTs7OztJQUVxQixrQjs7Ozs7Ozs7Ozs2QkFRVjtBQUFBLFVBQ0YsTUFERSxHQUNRLEtBQUssS0FEYixDQUNGLE1BREU7QUFBQSxVQUVGLElBRkUsR0FFTSxLQUFLLE9BRlgsQ0FFRixJQUZFOztBQUdQLFVBQUksaUJBQWlCLEtBQUssVUFBTCxDQUFnQixVQUFoQixHQUE2QixNQUFsRDtBQUNBLFVBQUksaUJBQWlCLENBQWpCLElBQXNCLGlCQUFpQixLQUFLLFVBQUwsQ0FBZ0IsU0FBM0QsRUFBc0U7QUFDcEUsZUFBTyxJQUFQO0FBQ0Q7QUFDRCxVQUFJLEtBQUssbUJBQW1CLENBQW5CLEdBQ0wsS0FBSyxVQUFMLEVBREssR0FFTCxLQUFLLFVBQUwsQ0FBZ0IsT0FBaEIsRUFBeUIsY0FBekIsQ0FGSjtBQUdBLGFBQU8sNEVBQVUsS0FBSyxLQUFmLElBQXNCLElBQUksRUFBMUIsSUFBUDtBQUNEOzs7RUFuQjZDLGdCQUFNLFM7Ozs7QUFBakMsa0IsQ0FFWixZLEdBQWU7QUFDcEIsVUFBUTtBQURZLEM7QUFGSCxrQixDQU1aLFk7a0JBTlksa0IiLCJmaWxlIjoiQ29sbGVjdGlvblBhZ2VMaW5rLmpzIiwic291cmNlc0NvbnRlbnQiOlsiLyoq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