Skip to content

Commit

Permalink
some adjustment updates
Browse files Browse the repository at this point in the history
  • Loading branch information
novalagung committed Jun 3, 2020
1 parent eb7fd35 commit c473495
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions adjustment.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,17 @@ func postAdjustment() {
htmlString = strings.Replace(htmlString, oldTitle, newTitle, -1)

// ==== adjust meta for SEO purpose
metaToFind := `<meta content=""name="description">`
metaReplacement := ""
if isLandingPage {
metaReplacement = `<meta content="Belajar Pemrograman Go Mulai Dari 0" name="description">`
}
metaReplacement = metaReplacement + `<script data-ad-client="` + adClient + `" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><script>(adsbygoogle = window.adsbygoogle || []).push({ google_ad_client: "` + adClient + `", enable_page_level_ads: true }); </script>`
htmlString = strings.Replace(htmlString, metaToFind, metaReplacement, -1)
htmlString = strings.Replace(htmlString, `<meta name="description" content="">`, metaReplacement, -1)

// ==== google ads
googleAdsToFind := `</head>`
// googleAdsReplacement := `<script data-ad-client="` + adClient + `" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">` + `</script><script>(adsbygoogle = window.adsbygoogle || []).push({ google_ad_client: "` + adClient + `", enable_page_level_ads: true }); </script>` + googleAdsToFind
googleAdsReplacement := `<script data-ad-client="` + adClient + `" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">` + googleAdsToFind
htmlString = strings.Replace(htmlString, googleAdsToFind, googleAdsReplacement, -1)

// ==== inject github stars button
buttonToFind := `</body>`
Expand All @@ -138,7 +142,7 @@ func postAdjustment() {
// bannerReplacement := `<a href="https://devops.novalagung.com/" target="_blank" class="book-news">Halo semua, Saya telah merilis ebook baru lo, tentang devops. Di ebook tersebut fokus tentang pembahasan banyak sekali stacks/teknologi devops, jadi tidak hanya membahas satu stack saja. Dan kabar baiknya tersedia dalam dua bahasa, Indonesia dan Inggris. Yuk mampir https://devops.novalagung.com/</a>` + bannerToFind
// htmlString = strings.Replace(htmlString, bannerToFind, bannerReplacement, -1)

// ===== inject info banner if exists
// ===== inject popup info banner if exists
infoBannerToFind := `</body>`
infoBannerReplacement := `<div class="banner-container" onclick="this.style.display = 'none';"><div><a target="_blank" href="https://www.udemy.com/course/praktis-belajar-docker-dan-kubernetes-untuk-pemula/"><img src="/images/banner.png?v=` + getVersion() + `"></a></div></div><script>var bannerCounter = parseInt(localStorage.getItem("banner-counter")); if (isNaN(bannerCounter)) { bannerCounter = 0; } var bannerEl = document.querySelector('.banner-container'); if (bannerCounter % 5 === 0 && bannerEl) { bannerEl.style.display = 'block'; } localStorage.setItem("banner-counter", String(bannerCounter + 1));</script>` + infoBannerToFind
htmlString = strings.Replace(htmlString, infoBannerToFind, infoBannerReplacement, -1)
Expand Down

0 comments on commit c473495

Please sign in to comment.