Skip to content

Add sponsor banner#57

Merged
HugoGresse merged 4 commits intomainfrom
add-sponso-banner
Apr 14, 2026
Merged

Add sponsor banner#57
HugoGresse merged 4 commits intomainfrom
add-sponso-banner

Conversation

@Razano26
Copy link
Copy Markdown
Contributor

No description provided.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 11, 2026

Visit the preview URL for this PR (updated for commit b0a08d2):

https://sunnytechwebsite--pr57-add-sponso-banner-gg3l9uxl.web.app

(expires Tue, 21 Apr 2026 15:15:18 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: b96ac7ab85879442bb94dc448b41aeca0f34d16c

@Razano26
Copy link
Copy Markdown
Contributor Author

image

@Razano26 Razano26 marked this pull request as ready for review April 14, 2026 08:27
Copilot AI review requested due to automatic review settings April 14, 2026 08:27
Signed-off-by: Louis Labeyrie <labeyrielouis@gmail.com>
@Razano26 Razano26 force-pushed the add-sponso-banner branch from 7d496b0 to 2024b69 Compare April 14, 2026 08:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a sponsor banner to the site layout, driven by OpenPlanner sponsor metadata, so selected sponsors can be highlighted globally.

Changes:

  • Extend the Sponsor type to include customFields.
  • Fetch OpenPlanner data in Layout.astro and compute bannerSponsors based on customFields['option-comm'].
  • Add a new SponsorBanner.astro component that renders sponsor logos and hides on scroll.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/type.ts Adds customFields to the Sponsor interface to support banner selection.
src/layouts/Layout.astro Fetches OpenPlanner data in the base layout and injects the SponsorBanner.
src/components/SponsorBanner.astro New component to render the sponsor banner UI and scroll-hide behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/layouts/Layout.astro Outdated
Comment thread src/layouts/Layout.astro Outdated
Comment on lines +13 to +21
}

const { title, description, metaImage } = Astro.props

const response = await fetch(OPENPLANNER_URL)
const openPlannerData: OpenPlannerType = await response.json()
const bannerSponsors = openPlannerData.sponsors.flatMap((cat) =>
cat.sponsors.filter((s) => s.customFields?.['option-comm'] === true)
)
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fetching OpenPlanner data inside the base Layout introduces duplicated network calls on pages that already fetch the same data (e.g. src/pages/index.astro, jobs.astro, schedule/speaker pages). This can significantly increase build time / external API load. Consider deduplicating via a shared getOpenPlannerData() helper with module-level caching, or by passing the already-fetched data (or computed bannerSponsors) into Layout as an optional prop so each page performs at most one fetch.

Suggested change
}
const { title, description, metaImage } = Astro.props
const response = await fetch(OPENPLANNER_URL)
const openPlannerData: OpenPlannerType = await response.json()
const bannerSponsors = openPlannerData.sponsors.flatMap((cat) =>
cat.sponsors.filter((s) => s.customFields?.['option-comm'] === true)
)
bannerSponsors?: OpenPlannerType['sponsors'][number]['sponsors']
}
const { title, description, metaImage, bannerSponsors: providedBannerSponsors } = Astro.props
const bannerSponsors =
providedBannerSponsors ??
(await (async () => {
const response = await fetch(OPENPLANNER_URL)
const openPlannerData: OpenPlannerType = await response.json()
return openPlannerData.sponsors.flatMap((cat) =>
cat.sponsors.filter((s) => s.customFields?.['option-comm'] === true)
)
})())

Copilot uses AI. Check for mistakes.
Comment thread src/components/SponsorBanner.astro Outdated
Comment on lines +29 to +34
window.addEventListener('scroll', () => {
const banner = document.querySelector('#sponsor-banner') as HTMLElement | null
if (banner) {
banner.classList.toggle('hidden', window.scrollY > 0)
}
})
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SponsorBanner.astro always registers a scroll event listener even when there is no banner rendered (when sponsors.length === 0), and it does a querySelector on every scroll. Consider only attaching the listener when the banner exists (or when sponsors.length > 0), caching the banner element outside the handler, and using a passive listener to reduce scroll overhead.

Suggested change
window.addEventListener('scroll', () => {
const banner = document.querySelector('#sponsor-banner') as HTMLElement | null
if (banner) {
banner.classList.toggle('hidden', window.scrollY > 0)
}
})
const banner = document.querySelector('#sponsor-banner') as HTMLElement | null
if (banner) {
const handleScroll = () => {
banner.classList.toggle('hidden', window.scrollY > 0)
}
handleScroll()
window.addEventListener('scroll', handleScroll, { passive: true })
}

Copilot uses AI. Check for mistakes.
Show "et X autre(s) sponsor(s)" after logos, excluding partners from the count.
- Wrap OpenPlanner fetch in try/catch with fallback to empty list (Copilot suggestion)
- Use template literal for "et X autres sponsors" to prevent prettier from splitting the expression across lines and adding unwanted whitespace
Cache banner ref outside handler and use passive listener for better scroll performance.
@HugoGresse HugoGresse merged commit b0ff302 into main Apr 14, 2026
3 checks passed
@HugoGresse HugoGresse deleted the add-sponso-banner branch April 14, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants