Skip to content

Commit 93c9de8

Browse files
committed
CSS Chnges
1 parent f726a76 commit 93c9de8

8 files changed

Lines changed: 141 additions & 469 deletions

File tree

src/components/AutoSubjectGrid.astro

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,24 +152,42 @@ const gridTitle = isLessonLevel ? "Course Lessons" : "Course Subjects";
152152
<h2 class="grid-title">Course Books & Resources</h2>
153153
<div class="book-grid">
154154
{textbooks.map((book) => {
155-
let coverColor = "#3b82f6"; // Default Blue
155+
const isMaths =
156+
book.slug.includes("maths-2") ||
157+
book.data.title.includes("Linear Algebra");
158+
const isStats =
159+
book.slug.includes("stats-2") ||
160+
book.data.title.includes("Probability");
161+
156162
let pattern = "circles";
163+
let fontStyle = "serif";
164+
let layoutStyle = "classic";
165+
let coverColor = book.data.cardColor || "#3b82f6";
157166

158-
if (book.data.title.includes("Stats")) {
159-
coverColor = "#ec4899"; // Pink/Rose
167+
if (isMaths) {
160168
pattern = "grid";
161-
} else if (book.data.title.includes("Calculus")) {
162-
coverColor = "#8b5cf6"; // Violet
169+
fontStyle = "sans";
170+
layoutStyle = "modern";
171+
coverColor = "#3b82f6"; // Ensure consistent blue
172+
} else if (isStats) {
163173
pattern = "waves";
174+
fontStyle = "serif";
175+
layoutStyle = "classic";
176+
// coverColor usually handled by book.data.cardColor but fallback:
177+
if (!book.data.cardColor) coverColor = "#ec4899";
164178
}
165179

166180
return (
167181
<BookCard
168-
title={book.data.title}
182+
title={book.data.title
183+
.replace("Book:", "")
184+
.trim()}
169185
subtitle={book.data.description}
170186
href={`/education/${book.slug}`}
171187
coverColor={coverColor}
172188
pattern={pattern as any}
189+
fontStyle={fontStyle as any}
190+
layoutStyle={layoutStyle as any}
173191
/>
174192
);
175193
})}
@@ -219,12 +237,11 @@ const gridTitle = isLessonLevel ? "Course Lessons" : "Course Subjects";
219237
}
220238

221239
.book-grid {
222-
display: grid;
223-
gap: 2rem;
224-
/* Uniform grid with fixed minimum width to prevent squashed cards */
225-
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
240+
display: flex;
241+
flex-wrap: wrap;
242+
justify-content: center;
243+
gap: 3rem;
226244
padding-top: 1rem;
227-
justify-items: center; /* Center cards in their cells */
228245
}
229246

230247
@media (max-width: 480px) {

src/components/BlogCard.astro

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ const cardStyle = lightColor
6767
/* Dark mode override */
6868
:global([data-theme="dark"]) .blog-card {
6969
background: var(--card-bg-dark, var(--color-surface));
70-
border-color: rgba(
70+
/* border-color: rgba(
7171
255,
7272
255,
7373
255,
7474
0.05
75-
); /* Subtle border on dark pastel */
75+
); Subtle border on dark pastel */
7676
}
7777

7878
.blog-card:hover {
@@ -147,6 +147,7 @@ const cardStyle = lightColor
147147
flex-direction: column;
148148
flex-grow: 1;
149149
gap: 0.75rem;
150+
background-color: var(--color-bg);
150151
}
151152

152153
.meta {

src/components/EducationCard.astro

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,19 @@ const isNew =
5252
data-tags={tags.join(",")}
5353
style={`--category-color: ${finalColor};`}
5454
>
55-
{isNew && <span class="new-sticker">NEW</span>}
56-
<span class="recently-opened-label">Opened Recently</span>
55+
<!-- Top Accent Line is handled by CSS ::before -->
56+
5757
<div class="card-header">
5858
<div class="institution-badge">
5959
<span class="institution">{institution}</span>
60-
61-
<span class="course-type" style={`color: ${finalColor}`}
62-
>{courseType}</span
63-
>
60+
<span class="course-type">{courseType}</span>
6461
</div>
62+
{isNew && <span class="new-indicator">NEW</span>}
6563
</div>
6664

6765
<div class="card-body">
6866
<h3 class="title">{title}</h3>
69-
<!-- <p class="description">{description}</p> -->
70-
<!--
71-
<div class="tags">
72-
{tags.slice(0, 3).map((tag) => <span class="tag">{tag}</span>)}
73-
</div> -->
7467
</div>
68+
69+
<!-- Hover overlay handled by CSS ::after -->
7570
</a>

src/components/ads/InArticleAd.astro

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
data-ad-format="fluid"
1616
data-ad-client="ca-pub-7993314093599705"
1717
data-ad-slot="8594941706"></ins>
18-
<script is:inline>
19-
(adsbygoogle = window.adsbygoogle || []).push({});
20-
</script>
2118
</div>
2219

2320
<style>

src/pages/blog/[...slug].astro

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,7 @@ const components = {
313313

314314
<script>
315315
import { insertAd } from "../../scripts/insertAd";
316-
// Using requestAnimationFrame to ensure DOM is ready and layout is settled
317-
requestAnimationFrame(() => {
316+
requestAnimationFrame(() => {
318317
insertAd('.prose', 'in-article-ad-source');
319318
});
320319
</script>

src/pages/index.astro

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ const posts = (await getCollection("blog"))
560560
/* font-family: "Montserrat", sans-serif; */
561561
/* font-family: "Playfair Display", serif; */
562562
/* font-family: "Inter", sans-serif; */
563-
font-family: var(--font-barlow);
563+
font-family: var(--font-barlow);
564564
font-size: 0.9rem;
565565
color: var(--color-primary);
566566
font-weight: 700;
@@ -620,10 +620,10 @@ const posts = (await getCollection("blog"))
620620
}
621621

622622
.books-grid {
623-
display: grid;
624-
grid-template-columns: repeat(4, 150px);
623+
display: flex;
624+
flex-wrap: wrap;
625625
justify-content: center;
626-
gap: 2rem;
626+
gap: 3rem;
627627
}
628628

629629
@media (max-width: 480px) {

src/scripts/insertAd.ts

Lines changed: 72 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,84 @@ export function insertAd(proseSelector: string, adContainerId: string) {
88
if (!prose || !adPlaceholder || !adContent) return;
99

1010
const headings = prose.querySelectorAll('h2');
11+
let primaryAdUsed = false;
1112

12-
// Rule 1: Insert after 3rd h2
13+
// Rule 1: Insert before 3rd h2
1314
if (headings.length >= 3) {
1415
headings[2].insertAdjacentElement('beforebegin', adContent);
15-
return;
16+
primaryAdUsed = true;
17+
try {
18+
((window as any).adsbygoogle = (window as any).adsbygoogle || []).push({});
19+
} catch (e) {
20+
console.error("AdSense push failed", e);
21+
}
1622
}
1723

18-
// Rule 2 & 3: Fallback to paragraphs
19-
const paragraphs = prose.querySelectorAll('p');
24+
// Rule 2: Insert before last h2 if > 4 headings
25+
// "more than 4 headings" usually means 5 or more.
26+
if (headings.length > 5) {
27+
const lastHeading = headings[headings.length - 1];
2028

21-
// Insert after 3rd paragraph
22-
if (paragraphs.length >= 3) {
23-
paragraphs[2].insertAdjacentElement('afterend', adContent);
29+
if (primaryAdUsed) {
30+
// Clone the ad for the second slot
31+
const adClone = adContent.cloneNode(true) as HTMLElement;
32+
33+
// Reset the 'ins' element in the clone to ensure a fresh ad request
34+
const ins = adClone.querySelector('ins');
35+
if (ins) {
36+
ins.removeAttribute('data-adsbygoogle-status');
37+
ins.removeAttribute('data-ad-status');
38+
ins.innerHTML = ''; // Clear any existing content/iframe
39+
}
40+
41+
lastHeading.insertAdjacentElement('beforebegin', adClone);
42+
43+
// Trigger ad load for the new slot
44+
try {
45+
((window as any).adsbygoogle = (window as any).adsbygoogle || []).push({});
46+
} catch (e) {
47+
console.error("AdSense push failed", e);
48+
}
49+
} else {
50+
// Capture this edge case if logic changes, though currently covered by Rule 1
51+
lastHeading.insertAdjacentElement('beforebegin', adContent);
52+
primaryAdUsed = true;
53+
try {
54+
((window as any).adsbygoogle = (window as any).adsbygoogle || []).push({});
55+
} catch (e) {
56+
console.error("AdSense push failed", e);
57+
}
58+
}
2459
}
25-
// Fallback: Append to end if article is very short
26-
else {
27-
prose.appendChild(adContent);
60+
61+
// Fallback: Paragraphs (only if no ads inserted yet)
62+
// The user said "also insert...". This implies the header rules function together.
63+
// The paragraph rule is a fallback if "no heading tag is there" (from previous prompt).
64+
// So if we inserted ANY ad in headers, we skip paragraphs.
65+
if (!primaryAdUsed) {
66+
const paragraphs = prose.querySelectorAll('p');
67+
68+
// Insert after 3rd paragraph
69+
if (paragraphs.length >= 3) {
70+
// Previous prompt said "after above 3rd paragraph" -> interpreted as after 3rd.
71+
// Wait, "after above 3rd paragraph" is ambiguous. "insert after above 3rd paragraph" -> maybe "insert after the paragraph that is above the 3rd one" (i.e. 2nd)?
72+
// Or "insert above 3rd paragraph" (before 3rd)?
73+
// Code in Step 153 used `afterend` on paragraphs[2] (after 3rd).
74+
// Let's stick to "After 3rd paragraph" as a reasonable default unless clarified.
75+
// Actually, let's use 'beforebegin' on the 3rd to match the "above" sentiment of header rule?
76+
// "if no heading tag is there then insert after above 3rd paragraph"
77+
// "after above 3rd paragraph" -> literally could mean "after the 3rd paragraph".
78+
// Let's stick to paragraphs[2].afterend (after 3rd).
79+
paragraphs[2].insertAdjacentElement('afterend', adContent);
80+
}
81+
// Fallback: Append to end
82+
else {
83+
prose.appendChild(adContent);
84+
}
85+
try {
86+
((window as any).adsbygoogle = (window as any).adsbygoogle || []).push({});
87+
} catch (e) {
88+
console.error("AdSense push failed", e);
89+
}
2890
}
2991
}

0 commit comments

Comments
 (0)