Skip to content

Commit

Permalink
Refactored our head code to support passing a cause into Raptive
Browse files Browse the repository at this point in the history
  • Loading branch information
Spicer Matthews committed Mar 12, 2024
1 parent fa2f67c commit 68f9f50
Show file tree
Hide file tree
Showing 3 changed files with 327 additions and 291 deletions.
17 changes: 0 additions & 17 deletions src/components/TabCMPHeadElements.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,6 @@ import React from 'react'
// https://github.com/gladly-team/tab-cmp/blob/master/src/tagModified.html
const TabCMPHeadElements = () => (
<>
<script
dangerouslySetInnerHTML={{
__html: `(function(w, d) {
w.adthrive = w.adthrive || {};
w.adthrive.cmd = w.adthrive.cmd || [];
w.adthrive.plugin = 'adthrive-ads-manual';
w.adthrive.host = 'ads.adthrive.com';
var s = d.createElement('script');
s.async = true;
s.referrerpolicy='no-referrer-when-downgrade';
s.src = 'https://' + w.adthrive.host + '/sites/655cd66352dfc71af0778a48/ads.min.js?referrer=' + w.encodeURIComponent(w.location.href) + '&cb=' + (Math.floor(Math.random() * 100) + 1);
var n = d.getElementsByTagName('script')[0];
n.parentNode.insertBefore(s, n);
})(window, document);`,
}}
/>

<script
type="text/javascript"
data-cfasync="false"
Expand Down
44 changes: 44 additions & 0 deletions src/components/head/Raptive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* eslint react/no-danger: 0 */
import React from 'react'
import PropTypes from 'prop-types'

export default function Raptive({ causeId }) {
return (

Check warning on line 6 in src/components/head/Raptive.js

View check run for this annotation

Codecov / codecov/patch

src/components/head/Raptive.js#L5-L6

Added lines #L5 - L6 were not covered by tests
<>
<script
dangerouslySetInnerHTML={{
__html: `(function(w, d) {
w.adthrive = w.adthrive || {};
w.adthrive.cmd = w.adthrive.cmd || [];
w.adthrive.plugin = 'adthrive-ads-manual';
w.adthrive.host = 'ads.adthrive.com';
var s = d.createElement('script');
s.async = true;
s.referrerpolicy='no-referrer-when-downgrade';
s.src = 'https://' + w.adthrive.host + '/sites/655cd66352dfc71af0778a48/ads.min.js?referrer=' + w.encodeURIComponent(w.location.href) + '&cb=' + (Math.floor(Math.random() * 100) + 1);
var n = d.getElementsByTagName('script')[0];
n.parentNode.insertBefore(s, n);
})(window, document);`,
}}
/>

<script
dangerouslySetInnerHTML={{
__html: `(function() {
window.adthrive.cmd.push(function() {
window.adthrive.siteAds.targeting.push( {key: 'at_custom_1', value: '${causeId}'} );
});
})();`,
}}
/>
</>
)
}

Raptive.propTypes = {
causeId: PropTypes.string,
}

Raptive.defaultProps = {
causeId: '',
}
Loading

0 comments on commit 68f9f50

Please sign in to comment.