Skip to content

Commit 418d3ff

Browse files
committed
fix: ethical ads integration
1 parent a72ea77 commit 418d3ff

File tree

8 files changed

+59
-4
lines changed

8 files changed

+59
-4
lines changed

frontend/src/components/banner/AdBanner.astro

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ const link = 'https://hexmos.com/livereview/';
5959
// Randomly select a variation
6060
const randomIndex = Math.floor(Math.random() * adVariations.length);
6161
const currentAd = adVariations[randomIndex];
62+
63+
// disable google ads for cheatsheet category pages, because there we using ethical ads
64+
const cheatsheetCategory = Astro.url?.pathname?.includes('/c/') ?? false;
6265
---
6366

6467
<div
@@ -241,4 +244,5 @@ const currentAd = adVariations[randomIndex];
241244
</div>
242245
</a>
243246
</div>
244-
<Banner type="banner" />
247+
{!cheatsheetCategory && <Banner type="banner" />}
248+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
export interface Props {
3+
keywords?: string[];
4+
style?: string;
5+
}
6+
7+
const { keywords = [], style = '' } = Astro.props;
8+
const eaKeywords = Array.isArray(keywords) ? keywords.join('|') : String(keywords);
9+
const mobileClass = 'ea-banner-mobile-center';
10+
---
11+
12+
<style>
13+
@media (max-width: 768px) {
14+
.ea-banner-mobile-center {
15+
display: flex !important;
16+
justify-content: center !important;
17+
align-items: center !important;
18+
width: 100% !important;
19+
margin: 24px 0 !important;
20+
}
21+
}
22+
</style>
23+
<script is:inline>
24+
if (!window.__ethicalAdsLoaded) {
25+
window.__ethicalAdsLoaded = true;
26+
var s = document.createElement('script');
27+
s.async = true;
28+
s.src = 'https://media.ethicalads.io/media/client/ethicalads.min.js';
29+
document.head.appendChild(s);
30+
}
31+
</script>
32+
33+
<div
34+
id="fdt-ethical-ads-image-ad"
35+
data-ea-publisher="hexmoscom"
36+
data-ea-type="image"
37+
data-ea-style="stickybox"
38+
data-ea-keywords={eaKeywords}
39+
class={mobileClass}
40+
style={style}
41+
></div>

frontend/src/pages/c/[category]/[name].astro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import ToolContainer from '../../../components/tool/ToolContainer';
77
import ToolHead from '../../../components/tool/ToolHead';
88
import BaseLayout from '../../../layouts/BaseLayout.astro';
99
import { getCheatsheet } from '../../../lib/cheatsheets-utils';
10+
import EABanner from '@/components/banner/EABanner.astro';
1011
1112
function processCheatsheetLinks(html: string): string {
1213
// First, add IDs to all headings (h1-h6) so anchor links work
@@ -167,7 +168,7 @@ const breadcrumbItems = [
167168

168169
<SeeAlsoIndex />
169170
<div class="mb-10">
170-
<Banner type="text" />
171+
<!-- <Banner type="text" /> -->
171172
</div>
172173

173174
<div class="mt-8 pt-6 mb-8 border-t border-slate-200 dark:border-slate-700">
@@ -187,5 +188,6 @@ const breadcrumbItems = [
187188
<CreditsButton href="/freedevtools/c/credits/" />
188189
</div>
189190
</div>
191+
<EABanner keywords={keywords} />
190192
</ToolContainer>
191193
</BaseLayout>

frontend/src/pages/c/[category]/[page].astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,6 @@ const keywords = [
9898
totalPages={totalPages}
9999
seoDescription={seoDescription}
100100
breadcrumbItems={breadcrumbItems}
101+
keywords={keywords}
101102
/>
102103
</BaseLayout>

frontend/src/pages/c/[category]/_CategoryCheatsheetsPage.astro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import CreditsButton from '../../../components/buttons/CreditsButton';
44
import ToolContainer from '../../../components/tool/ToolContainer';
55
import ToolHead from '../../../components/tool/ToolHead';
66
import AdBanner from '../../../components/banner/AdBanner.astro';
7-
7+
import EABanner from '@/components/banner/EABanner.astro';
88
const {
99
categoryName,
1010
categorySlug,
@@ -14,6 +14,7 @@ const {
1414
totalPages,
1515
seoDescription,
1616
breadcrumbItems,
17+
keywords,
1718
} = Astro.props;
1819
---
1920

@@ -93,6 +94,7 @@ const {
9394
<CreditsButton href="/freedevtools/c/credits/" />
9495
</div>
9596
</div>
97+
<EABanner keywords={keywords} />
9698
</ToolContainer>
9799

98100
<script>

frontend/src/pages/c/[page].astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,6 @@ const mainKeywords = [
8484
totalCategories={totalCategories}
8585
totalCheatsheets={totalCheatsheets}
8686
breadcrumbItems={breadcrumbItems}
87+
keywords={mainKeywords}
8788
/>
8889
</BaseLayout>

frontend/src/pages/c/_CheatsheetPage.astro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import Pagination from '../../components/PaginationComponent.astro';
44
import ToolContainer from '../../components/tool/ToolContainer';
55
import ToolHead from '../../components/tool/ToolHead';
66
import AdBanner from '../../components/banner/AdBanner.astro';
7-
7+
import EABanner from '@/components/banner/EABanner.astro';
88
const {
99
categories,
1010
currentPage,
1111
totalPages,
1212
totalCategories,
1313
totalCheatsheets,
1414
breadcrumbItems,
15+
keywords,
1516
} = Astro.props;
1617
---
1718

@@ -117,6 +118,7 @@ const {
117118
<CreditsButton href="/freedevtools/c/credits/" />
118119
</div>
119120
</div>
121+
<EABanner keywords={keywords} />
120122
</ToolContainer>
121123

122124
<script>

frontend/src/pages/c/index.astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import BaseLayout from '../../layouts/BaseLayout.astro';
33
import { generateCheatsheetStaticPaths, getAllCheatsheetCategories } from '../../lib/cheatsheets-utils';
44
import CheatsheetPage from './_CheatsheetPage.astro';
5+
import EABanner from '@/components/banner/EABanner.astro';
56
67
export async function getStaticPaths() {
78
return await generateCheatsheetStaticPaths();
@@ -82,4 +83,5 @@ const mainKeywords = [
8283
totalCheatsheets={totalCheatsheets}
8384
breadcrumbItems={breadcrumbItems}
8485
/>
86+
<EABanner keywords={mainKeywords} />
8587
</BaseLayout>

0 commit comments

Comments
 (0)