const GhostContent = ({ html }) => {
  var ref = React.useRef(null);

  React.useEffect(function () {
    if (!ref.current) return;
    var scripts = ref.current.querySelectorAll('script');
    scripts.forEach(function (s) { s.remove(); });
    var links = ref.current.querySelectorAll('a[href^="http"]');
    links.forEach(function (a) {
      a.setAttribute('target', '_blank');
      a.setAttribute('rel', 'noopener noreferrer');
    });
  }, [html]);

  if (!html) return null;

  return React.createElement('div', {
    ref: ref,
    className: 'gh-content ib-post-body',
    dangerouslySetInnerHTML: { __html: html },
  });
};

window.GhostContent = GhostContent;
