{"ast":null,"code":"import _Reflect$construct from \"@babel/runtime-corejs2/core-js/reflect/construct\";\nimport _regeneratorRuntime from \"@babel/runtime-corejs2/regenerator\";\nimport _asyncToGenerator from \"@babel/runtime-corejs2/helpers/asyncToGenerator\";\nimport _extends from \"@babel/runtime-corejs2/helpers/extends\";\nimport _classCallCheck from \"@babel/runtime-corejs2/helpers/classCallCheck\";\nimport _createClass from \"@babel/runtime-corejs2/helpers/createClass\";\nimport _inherits from \"@babel/runtime-corejs2/helpers/inherits\";\nimport _possibleConstructorReturn from \"@babel/runtime-corejs2/helpers/possibleConstructorReturn\";\nimport _getPrototypeOf from \"@babel/runtime-corejs2/helpers/getPrototypeOf\";\nimport _JSXStyle from \"styled-jsx/style\";\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function () { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(_Reflect$construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nimport * as React from \"react\";\nimport TimeAgo from \"react-timeago\";\nimport NextLink from \"next/link\";\nimport Header from \"../components/header\";\nimport Body from \"../components/body\";\nimport { getJSON } from \"../shims/ajax\";\n\nvar Authors = function Authors(props) {\n  return /*#__PURE__*/React.createElement(\"span\", {\n    className: \"authors\"\n  }, props.authors.map(function (author) {\n    return author.name;\n  }).join(\", \"));\n};\n\nvar Tag = function Tag(props) {\n  return /*#__PURE__*/React.createElement(\"span\", {\n    className: \"jsx-3711646761\"\n  }, /*#__PURE__*/React.createElement(\"span\", {\n    className: \"jsx-3711646761\" + \" \" + \"tag\"\n  }, props.children), /*#__PURE__*/React.createElement(_JSXStyle, {\n    id: \"3711646761\"\n  }, [\".tag.jsx-3711646761{display:inline-block;padding:0.2em 0.9em;margin:0 0.5em 0.5em 0;white-space:nowrap;background-color:#f1f8ff;border-radius:3px;color:#0366d6;-webkit-text-decoration:none;text-decoration:none;}\", \"tag.jsx-3711646761:hover{background-color:#ddeeff;}\"]));\n};\n\nvar DiscoveryItem = function DiscoveryItem(props) {\n  return /*#__PURE__*/React.createElement(\"div\", {\n    className: \"jsx-4254359129\" + \" \" + \"post\"\n  }, /*#__PURE__*/React.createElement(\"div\", {\n    className: \"jsx-4254359129\" + \" \" + \"post-thumb\"\n  }, /*#__PURE__*/React.createElement(\"img\", {\n    alt: \"preview for \".concat(props.path),\n    src: props.image ? props.image : \"https://icon.now.sh/library_books/ccc/64\",\n    height: \"64\",\n    className: \"jsx-4254359129\"\n  })), /*#__PURE__*/React.createElement(\"div\", {\n    className: \"jsx-4254359129\" + \" \" + \"post-summary\"\n  }, /*#__PURE__*/React.createElement(\"h3\", {\n    className: \"jsx-4254359129\" + \" \" + \"post-title\"\n  }, /*#__PURE__*/React.createElement(NextLink, {\n    href: {\n      pathname: \"/view\",\n      query: {\n        viewPath: props.path\n      }\n    },\n    as: \"/view/\" + props.path\n  }, /*#__PURE__*/React.createElement(\"a\", {\n    className: \"jsx-4254359129\"\n  }, props.metadata.title ? props.metadata.title : props.name))), /*#__PURE__*/React.createElement(\"div\", {\n    className: \"jsx-4254359129\" + \" \" + \"post-metadata\"\n  }, /*#__PURE__*/React.createElement(\"span\", {\n    className: \"jsx-4254359129\"\n  }, \"Last modified \", /*#__PURE__*/React.createElement(TimeAgo, {\n    date: props.last_modified\n  })), \" \", props.metadata.authors ? /*#__PURE__*/React.createElement(\"span\", {\n    className: \"jsx-4254359129\"\n  }, \"by \", /*#__PURE__*/React.createElement(Authors, {\n    authors: props.metadata.authors\n  })) : null), /*#__PURE__*/React.createElement(\"div\", {\n    className: \"jsx-4254359129\" + \" \" + \"post-description\"\n  }, /*#__PURE__*/React.createElement(\"p\", {\n    className: \"jsx-4254359129\"\n  }, props.metadata.nteract.description)), /*#__PURE__*/React.createElement(\"div\", {\n    className: \"jsx-4254359129\" + \" \" + \"post-tags\"\n  }, props.metadata.nteract.tags.map(function (tag) {\n    return /*#__PURE__*/React.createElement(Tag, {\n      key: tag\n    }, tag);\n  }))), /*#__PURE__*/React.createElement(_JSXStyle, {\n    id: \"4254359129\"\n  }, [\".post.jsx-4254359129{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;border-bottom:1px #e1e4e8 solid !important;padding-top:24px !important;padding-bottom:24px !important;}\", \"h3.jsx-4254359129{font-size:20px;font-weight:600;margin-top:0;margin-bottom:4px;}\", \"a.jsx-4254359129{color:#0366d6;-webkit-text-decoration:none;text-decoration:none;}\", \".post-metadata.jsx-4254359129{font-style:italic;}\", \".post-metadata.jsx-4254359129,.post-description.jsx-4254359129{color:#586069 !important;}\", \".post-summary.jsx-4254359129{margin-left:2rem;}\", \".post-tags.jsx-4254359129{margin-top:0.5rem;}\"]));\n};\n\nvar DiscoveryGrid = /*#__PURE__*/function (_React$Component) {\n  _inherits(DiscoveryGrid, _React$Component);\n\n  var _super = _createSuper(DiscoveryGrid);\n\n  function DiscoveryGrid() {\n    _classCallCheck(this, DiscoveryGrid);\n\n    return _super.apply(this, arguments);\n  }\n\n  _createClass(DiscoveryGrid, [{\n    key: \"render\",\n    value: function render() {\n      if (this.props.discovered.length === 0) {\n        return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Header, null), /*#__PURE__*/React.createElement(Body, null, /*#__PURE__*/React.createElement(\"h1\", null, \"No discoveries...\")));\n      }\n\n      return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Header, {\n        active: \"discover\"\n      }), /*#__PURE__*/React.createElement(Body, null, /*#__PURE__*/React.createElement(\"div\", {\n        className: \"jsx-3819645876\" + \" \" + \"discoveries\"\n      }, this.props.discovered ? this.props.discovered.map(function (item) {\n        return /*#__PURE__*/React.createElement(DiscoveryItem, _extends({\n          key: item.path\n        }, item));\n      }) : null), /*#__PURE__*/React.createElement(_JSXStyle, {\n        id: \"3819645876\"\n      }, [\".discoveries.jsx-3819645876{margin-top:1rem;margin-left:1rem;margin-right:1rem;}\", \".discoveries.jsx-3819645876>*.jsx-3819645876{display:block;}\"])));\n    }\n  }], [{\n    key: \"getInitialProps\",\n    value: function () {\n      var _getInitialProps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(context) {\n        var req, BASE_PATH, port, url, xhr;\n        return _regeneratorRuntime.wrap(function _callee$(_context) {\n          while (1) {\n            switch (_context.prev = _context.next) {\n              case 0:\n                req = context.req;\n\n                if (req) {\n                  // Server side, communicate with our local API\n                  port = process.env.COMMUTER_PORT || 4000;\n                  BASE_PATH = \"http://127.0.0.1:\".concat(port, \"/\");\n                } else {\n                  BASE_PATH = \"/\";\n                }\n\n                url = \"\".concat(BASE_PATH, \"api/v1/discovery\");\n                _context.next = 5;\n                return getJSON(url).toPromise();\n\n              case 5:\n                xhr = _context.sent;\n                return _context.abrupt(\"return\", {\n                  discovered: xhr.response.results,\n                  statusCode: xhr.status\n                });\n\n              case 7:\n              case \"end\":\n                return _context.stop();\n            }\n          }\n        }, _callee);\n      }));\n\n      function getInitialProps(_x) {\n        return _getInitialProps.apply(this, arguments);\n      }\n\n      return getInitialProps;\n    }()\n  }]);\n\n  return DiscoveryGrid;\n}(React.Component);\n\nexport default DiscoveryGrid;","map":null,"metadata":{},"sourceType":"module"}