"use strict";

exports.__esModule = true;
exports.ArticleCard = void 0;

var _react = _interopRequireDefault(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _stringHash = _interopRequireDefault(require("string-hash"));

var _LinkTo = require("../LinkTo");

var _utils = require("../../utils");

var _DragonKitContext = require("../../context/DragonKitContext");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var ArticleContent = function ArticleContent(_ref) {
  var publishDate = _ref.publishDate,
      category = _ref.category,
      title = _ref.title;
  return /*#__PURE__*/_react.default.createElement("div", {
    className: "content"
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: "inner"
  }, /*#__PURE__*/_react.default.createElement("time", {
    dateTime: publishDate
  }, publishDate), /*#__PURE__*/_react.default.createElement("div", {
    className: "category"
  }, category), /*#__PURE__*/_react.default.createElement("h2", {
    className: "title"
  }, /*#__PURE__*/_react.default.createElement("span", null, title))));
};

var ArticleCard = function ArticleCard(_ref2) {
  var category = _ref2.category,
      publishDate = _ref2.publishDate,
      title = _ref2.title,
      slug = _ref2.slug,
      image = _ref2.image;

  var _useDragonKitValue = (0, _DragonKitContext.useDragonKitValue)(),
      dragonKit = _useDragonKitValue[0];

  var hash = image && (0, _stringHash.default)(image);
  var imageClasses = (0, _classnames.default)('img', "rbiHandler-" + hash);
  return /*#__PURE__*/_react.default.createElement("div", {
    className: "blog-article-card"
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: "inner"
  }, /*#__PURE__*/_react.default.createElement(_LinkTo.LinkTo, {
    type: "route",
    url: "" + dragonKit.blogUrl + slug
  }, /*#__PURE__*/_react.default.createElement(ArticleContent, {
    publishDate: publishDate,
    category: category,
    title: title
  }), /*#__PURE__*/_react.default.createElement("div", {
    className: "image"
  }, (0, _utils.BackgroundImage)(image, hash), /*#__PURE__*/_react.default.createElement("div", {
    className: "inner"
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: imageClasses
  }), /*#__PURE__*/_react.default.createElement("img", {
    src: image,
    alt: "blockchain article"
  }))))));
};

ArticleCard.displayName = 'Article Card';
var ArticleCardDoc;

if (process.env.NODE_ENV !== 'production') {
  // eslint-disable-next-line global-require
  ArticleCardDoc = require('./doc').doc(ArticleCard);
}

var ArticleCardWrapper = ArticleCardDoc || ArticleCard;
exports.ArticleCard = ArticleCardWrapper;