Ad.tsx 708 B

12345678910111213141516171819202122
  1. 'use client';
  2. import clsx from 'clsx';
  3. import { useRef, useEffect } from 'react';
  4. export default function Ad({ className, horizontal }: { className?: string; horizontal?: boolean }) {
  5. const ad = useRef<any>(null);
  6. useEffect(() => {
  7. if (ad.current && process.env.NODE_ENV !== 'development') {
  8. ad.current.innerHTML = '';
  9. const script = document.createElement('script');
  10. script.async = true;
  11. script.src = '//cdn.carbonads.com/carbon.js?serve=CWYDCKQE&placement=tabler-iconsio';
  12. script.id = '_carbonads_js';
  13. ad.current.appendChild(script);
  14. }
  15. }, []);
  16. return <div ref={ad} className={clsx('carbon', className, horizontal && 'carbon-horizontal')}></div>;
  17. };