@bebranded/bb-contents 1.0.41-beta → 1.0.42-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bb-contents.js +14 -2
- package/package.json +1 -1
package/bb-contents.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BeBranded Contents
|
|
3
3
|
* Contenus additionnels français pour Webflow
|
|
4
|
-
* @version 1.0.
|
|
4
|
+
* @version 1.0.42-beta
|
|
5
5
|
* @author BeBranded
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @website https://www.bebranded.xyz
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
// Configuration
|
|
19
19
|
const config = {
|
|
20
|
-
version: '1.0.
|
|
20
|
+
version: '1.0.42-beta',
|
|
21
21
|
debug: true, // Activé temporairement pour debug
|
|
22
22
|
prefix: 'bb-', // utilisé pour générer les sélecteurs (data-bb-*)
|
|
23
23
|
youtubeEndpoint: null, // URL du worker YouTube (à définir par l'utilisateur)
|
|
@@ -600,6 +600,7 @@
|
|
|
600
600
|
this.cleanCache();
|
|
601
601
|
|
|
602
602
|
const elements = scope.querySelectorAll('[bb-youtube-channel]');
|
|
603
|
+
console.log('[DEBUG] YouTube elements found:', elements.length);
|
|
603
604
|
if (elements.length === 0) return;
|
|
604
605
|
|
|
605
606
|
// Module détecté: youtube
|
|
@@ -618,6 +619,8 @@
|
|
|
618
619
|
const language = bbContents._getAttr(element, 'bb-youtube-language') || 'fr';
|
|
619
620
|
const endpoint = bbContents.config.youtubeEndpoint;
|
|
620
621
|
|
|
622
|
+
console.log('[DEBUG] YouTube config:', {channelId, videoCount, allowShorts, language, endpoint});
|
|
623
|
+
|
|
621
624
|
if (!channelId) {
|
|
622
625
|
// Erreur: bb-youtube-channel manquant
|
|
623
626
|
return;
|
|
@@ -668,14 +671,17 @@
|
|
|
668
671
|
container.innerHTML = '<div style="padding: 20px; text-align: center; color: #6b7280;">Chargement des vidéos YouTube...</div>';
|
|
669
672
|
|
|
670
673
|
// Appeler l'API via le Worker
|
|
674
|
+
console.log('[DEBUG] Fetching YouTube data from:', `${endpoint}?channelId=${channelId}&maxResults=${videoCount}&allowShorts=${allowShorts}`);
|
|
671
675
|
fetch(`${endpoint}?channelId=${channelId}&maxResults=${videoCount}&allowShorts=${allowShorts}`)
|
|
672
676
|
.then(response => {
|
|
677
|
+
console.log('[DEBUG] YouTube API response status:', response.status);
|
|
673
678
|
if (!response.ok) {
|
|
674
679
|
throw new Error(`HTTP ${response.status}`);
|
|
675
680
|
}
|
|
676
681
|
return response.json();
|
|
677
682
|
})
|
|
678
683
|
.then(data => {
|
|
684
|
+
console.log('[DEBUG] YouTube API data received:', data);
|
|
679
685
|
if (data.error) {
|
|
680
686
|
throw new Error(data.error.message || 'Erreur API YouTube');
|
|
681
687
|
}
|
|
@@ -687,6 +693,7 @@
|
|
|
687
693
|
this.generateYouTubeFeed(container, template, data, allowShorts, language);
|
|
688
694
|
})
|
|
689
695
|
.catch(error => {
|
|
696
|
+
console.error('[DEBUG] YouTube API error:', error);
|
|
690
697
|
// Erreur dans le module youtube
|
|
691
698
|
|
|
692
699
|
// En cas d'erreur, essayer de récupérer du cache même expiré
|
|
@@ -694,10 +701,12 @@
|
|
|
694
701
|
if (expiredCache) {
|
|
695
702
|
try {
|
|
696
703
|
const cachedData = JSON.parse(expiredCache);
|
|
704
|
+
console.log('[DEBUG] Using expired cache:', cachedData);
|
|
697
705
|
// Utilisation du cache expiré en cas d'erreur API
|
|
698
706
|
this.generateYouTubeFeed(container, template, cachedData.value, allowShorts, language);
|
|
699
707
|
return;
|
|
700
708
|
} catch (e) {
|
|
709
|
+
console.error('[DEBUG] Cache parsing error:', e);
|
|
701
710
|
// Ignorer les erreurs de parsing
|
|
702
711
|
}
|
|
703
712
|
}
|
|
@@ -708,13 +717,16 @@
|
|
|
708
717
|
},
|
|
709
718
|
|
|
710
719
|
generateYouTubeFeed: function(container, template, data, allowShorts, language = 'fr') {
|
|
720
|
+
console.log('[DEBUG] generateYouTubeFeed called with data:', data);
|
|
711
721
|
if (!data.items || data.items.length === 0) {
|
|
722
|
+
console.log('[DEBUG] No videos found in data');
|
|
712
723
|
container.innerHTML = '<div style="padding: 20px; text-align: center; color: #6b7280;">Aucune vidéo trouvée</div>';
|
|
713
724
|
return;
|
|
714
725
|
}
|
|
715
726
|
|
|
716
727
|
// Les vidéos sont déjà filtrées par l'API YouTube selon allowShorts
|
|
717
728
|
let videos = data.items;
|
|
729
|
+
console.log('[DEBUG] Processing', videos.length, 'videos');
|
|
718
730
|
// Vidéos reçues de l'API
|
|
719
731
|
|
|
720
732
|
// Vider le conteneur (en préservant les éléments marquee)
|