@bebranded/bb-contents 1.0.40-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.
Files changed (2) hide show
  1. package/bb-contents.js +17 -5
  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.40-beta
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.40-beta',
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)
@@ -203,7 +203,7 @@
203
203
 
204
204
  // Modules
205
205
  bbContents.modules = {
206
- // Module Marquee - Version live 1.0.40-beta avec modules parasites supprimés
206
+ // Module Marquee - Version live 1.0.41-beta avec modules parasites supprimés
207
207
  marquee: {
208
208
  detect: function(scope) {
209
209
  const s = scope || document;
@@ -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;
@@ -625,7 +628,7 @@
625
628
 
626
629
  if (!endpoint) {
627
630
  // Erreur: youtubeEndpoint non configuré
628
- element.innerHTML = '<div style="padding: 20px; background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; color: #dc2626;"><strong>Configuration YouTube manquante</strong><br>Ajoutez dans le &lt;head&gt; :<br><code style="display: block; background: #f3f4f6; padding: 10px; margin: 10px 0; border-radius: 4px; font-family: monospace;">&lt;script&gt;<br>bbContents.config.youtubeEndpoint = \'https://youtube-worker.maxkonzelmann.workers.dev\';<br>&lt;/script&gt;</code></div>';
631
+ element.innerHTML = '<div style="padding: 20px; background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; color: #dc2626;"><strong>Configuration YouTube manquante</strong><br>Ajoutez dans le &lt;head&gt; :<br><code style="display: block; background: #f3f4f6; padding: 10px; margin: 10px 0; border-radius: 4px; font-family: monospace;">&lt;script&gt;<br>bbContents.config.youtubeEndpoint = \'votre-worker-url\';<br>&lt;/script&gt;</code></div>';
629
632
  return;
630
633
  }
631
634
 
@@ -660,7 +663,7 @@
660
663
 
661
664
  if (cachedData) {
662
665
  // Données YouTube récupérées du cache (économie API)
663
- this.generateYouTubeFeed(container, template, cachedData, allowShorts, language);
666
+ this.generateYouTubeFeed(container, template, cachedData.value, allowShorts, language);
664
667
  return;
665
668
  }
666
669
 
@@ -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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bebranded/bb-contents",
3
- "version": "1.0.40-beta",
3
+ "version": "1.0.42-beta",
4
4
  "description": "Contenus additionnels français pour Webflow",
5
5
  "main": "bb-contents.js",
6
6
  "scripts": {