thibaud frere commited on
Commit
89de168
·
1 Parent(s): f1ef9f0
app/scripts/export-pdf.mjs CHANGED
@@ -149,7 +149,9 @@ async function main() {
149
  } catch {}
150
  }, theme);
151
  const page = await context.newPage();
152
- await page.goto(baseUrl, { waitUntil: 'networkidle', timeout: 60000 });
 
 
153
  // Compute slug from title if needed
154
  if (!args.filename) {
155
  const title = await page.evaluate(() => {
 
149
  } catch {}
150
  }, theme);
151
  const page = await context.newPage();
152
+ await page.goto(baseUrl, { waitUntil: 'load', timeout: 60000 });
153
+ // Give time for CDN scripts (Plotly/D3) to attach and for our fragment hooks to run
154
+ try { await page.waitForFunction(() => !!window.Plotly, { timeout: 8000 }); } catch {}
155
  // Compute slug from title if needed
156
  if (!args.filename) {
157
  const title = await page.evaluate(() => {
app/src/components/HtmlFragment.astro CHANGED
@@ -51,8 +51,8 @@ const mountId = `frag-${Math.random().toString(36).slice(2)}`;
51
  }
52
  });
53
  };
54
- // If Plotly isn't loaded yet, wait for the window load event
55
- if (window.Plotly) execute();
56
  else window.addEventListener('load', execute, { once: true });
57
  </script>
58
 
 
51
  }
52
  });
53
  };
54
+ // Ensure execution when ready: run now if Plotly is present or document already loaded; otherwise wait for 'load'
55
+ if (window.Plotly || document.readyState === 'complete') execute();
56
  else window.addEventListener('load', execute, { once: true });
57
  </script>
58
 
app/src/styles/components/_code.scss CHANGED
@@ -9,11 +9,9 @@ section.content-grid pre { overflow-x: auto; width: 100%; max-width: 100%; box-s
9
  section.content-grid pre code { display: inline-block; min-width: 100%; }
10
 
11
  /* Wrap long lines on mobile to avoid overflow (URLs, etc.) */
12
- @media (max-width: 1100px) {
13
- .astro-code,
14
- section.content-grid pre { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
15
- section.content-grid pre code { white-space: pre-wrap; display: block; min-width: 0; }
16
- }
17
 
18
  html[data-theme='light'] .astro-code { background-color: var(--code-bg); }
19
 
 
9
  section.content-grid pre code { display: inline-block; min-width: 100%; }
10
 
11
  /* Wrap long lines on mobile to avoid overflow (URLs, etc.) */
12
+ .astro-code,
13
+ section.content-grid pre { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
14
+ section.content-grid pre code { white-space: pre-wrap; display: block; min-width: 0; }
 
 
15
 
16
  html[data-theme='light'] .astro-code { background-color: var(--code-bg); }
17