diff --git a/edsdme/blocks/announcements-preview/announcements-preview.js b/edsdme/blocks/announcements-preview/announcements-preview.js index 62f0012..ced7837 100644 --- a/edsdme/blocks/announcements-preview/announcements-preview.js +++ b/edsdme/blocks/announcements-preview/announcements-preview.js @@ -1,5 +1,6 @@ import { getCaasUrl } from '../../scripts/utils.js'; import { getConfig } from '../utils/utils.js'; +import { filterRestrictedCardsByCurrentSite } from '../../components/PartnerCards.js'; function addAnnouncement(cardData) { const linkWrapper = document.createElement('a'); @@ -62,6 +63,8 @@ async function fetchData(blockData, newestCards) { apiData = await response.json(); if (apiData?.cards) { + // Filter announcements by current site + apiData.cards = filterRestrictedCardsByCurrentSite(apiData.cards); apiData.cards.forEach((card) => { const cardDate = new Date(card.cardDate); if (newestCards.length < 3) { diff --git a/edsdme/blocks/logos/LogosCards.js b/edsdme/blocks/logos/LogosCards.js index 887589a..3e04aa5 100644 --- a/edsdme/blocks/logos/LogosCards.js +++ b/edsdme/blocks/logos/LogosCards.js @@ -1,6 +1,6 @@ import { getLibs } from '../../scripts/utils.js'; import PartnerCards from '../../components/PartnerCards.js'; -import { searchCardsStyles } from '../search/SearchCardsStyles.js'; +import { searchCardsStyles } from '../search-full/SearchCardsStyles.js'; import '../../components/SearchCard.js'; import { generateRequestForSearchAPI } from '../utils/utils.js'; diff --git a/edsdme/components/PartnerCards.js b/edsdme/components/PartnerCards.js index 9b1ffc9..83cdfe9 100644 --- a/edsdme/components/PartnerCards.js +++ b/edsdme/components/PartnerCards.js @@ -5,6 +5,16 @@ import './SinglePartnerCard.js'; const miloLibs = getLibs(); const { html, LitElement, css, repeat } = await import(`${miloLibs}/deps/lit-all.min.js`); +export function filterRestrictedCardsByCurrentSite(cards) { + const currentSite = window.location.pathname.split('/')[1]; + return cards.filter((card) => { + const cardUrl = card?.contentArea?.url; + if (!cardUrl) return false; + const cardSite = new URL(cardUrl).pathname.split('/')[1]; + return currentSite === cardSite; + }); +} + export default class PartnerCards extends LitElement { static styles = [ partnerCardsStyles, @@ -185,6 +195,8 @@ export default class PartnerCards extends LitElement { if (window.location.hostname === 'partners.adobe.com') { apiData.cards = apiData.cards.filter((card) => !card.contentArea.url?.includes('/drafts/')); } + // Filter announcements by current site + apiData.cards = filterRestrictedCardsByCurrentSite(apiData.cards); // eslint-disable-next-line no-return-assign apiData.cards.forEach((card, index) => card.orderNum = index + 1); this.allCards = apiData.cards;