Skip to content

Instantly share code, notes, and snippets.

@mariolopjr
Last active January 7, 2018 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariolopjr/55102b18b40b4c682f434ce482ce6a70 to your computer and use it in GitHub Desktop.
Save mariolopjr/55102b18b40b4c682f434ce482ce6a70 to your computer and use it in GitHub Desktop.
Add block under posts for affiliate links
var ads = `
<article class="read-next-card" style="background-image: url(/content/images/2018/01/blog.jpg)">
<header class="read-next-card-header">
<small class="read-next-card-header-sitetitle">— techmunchies —</small>
<h3 class="read-next-card-header-title"><a href="#">Affiliates</a></h3>
</header>
<div class="read-next-divider"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 14.5s2 3 5 3 5.5-2.463 5.5-5.5S21 6.5 18 6.5c-5 0-7 11-12 11C2.962 17.5.5 15.037.5 12S3 6.5 6 6.5s4.5 3.5 4.5 3.5"></path></svg>
</div>
<div class="read-next-card-content">
<ul>
<li>
<a href="https://www.vultr.com/?ref=7302183" target="_blank">
<img src="https://www.vultr.com/media/badge_onblue.svg" alt="Host by Vultr - Starting at $2.50/mo" title="Host by Vultr - Starting at $2.50/mo" style="width:205px;">
</a>
</li>
</ul>
</div>
</article>
`;
var n = $('.read-next-feed');
var num = $('.read-next-feed article').length;
if ( num === 3 ) {
n.children().last().remove();
n.append(ads);
}
else if ( num === 2 ) {
n.append(ads);
}
var ads=`<article class="read-next-card" style="background-image: url(/content/images/2018/01/blog.jpg)"> <header class="read-next-card-header"> <small class="read-next-card-header-sitetitle">— techmunchies —</small> <h3 class="read-next-card-header-title"><a href="#">Affiliates</a></h3> </header> <div class="read-next-divider"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 14.5s2 3 5 3 5.5-2.463 5.5-5.5S21 6.5 18 6.5c-5 0-7 11-12 11C2.962 17.5.5 15.037.5 12S3 6.5 6 6.5s4.5 3.5 4.5 3.5"></path></svg> </div><div class="read-next-card-content"> <ul> <li> <a href="https://www.vultr.com/?ref=7302183" target="_blank"> <img src="https://www.vultr.com/media/badge_onblue.svg" alt="Host by Vultr - Starting at $2.50/mo" title="Host by Vultr - Starting at $2.50/mo" style="width:205px;"> </a> </li></ul> </div></article>`;var n=$('.read-next-feed');var num=$('.read-next-feed article').length;if ( num===3 ){n.children().last().remove(); n.append(ads);}else if ( num===2 ){n.append(ads);}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment