Skip to content

Commit 36da6a1

Browse files
committed
fix: enhance slide loading and error handling in WorkflowHero component
1 parent 6ee5825 commit 36da6a1

4 files changed

Lines changed: 25 additions & 8 deletions

File tree

.github/workflows/docs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ jobs:
4949
steps:
5050
- name: Checkout repository
5151
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
52+
with:
53+
lfs: true
5254

5355
- name: Setup Node.js
5456
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"start": "astro dev",
1111
"prebuild": "npm run generate-agent-factory && npm run generate-model-tables && npm run build:slides",
1212
"build": "rm -rf dist && astro build",
13-
"build:slides": "mkdir -p public/slides && cp slides/github-agentic-workflows.pdf public/slides/github-agentic-workflows.pdf",
13+
"build:slides": "head -c 5 slides/github-agentic-workflows.pdf | grep -q '%PDF-' && mkdir -p public/slides && cp slides/github-agentic-workflows.pdf public/slides/github-agentic-workflows.pdf || (echo 'slides/github-agentic-workflows.pdf is not a real PDF. Did checkout skip Git LFS?' >&2; exit 1)",
1414
"preview": "astro preview",
1515
"astro": "astro",
1616
"validate-links": "astro build",

docs/src/components/WorkflowHero.astro

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,27 @@ const deck = {
3232
const root = document.querySelector('[data-slide-hero]');
3333
if (!root) throw new Error('Slide hero root not found');
3434

35+
/** @type {HTMLElement | null} */
36+
let heroRoot = null;
37+
3538
function mountIntoHero() {
3639
const hero = document.querySelector('.hero');
37-
if (!hero || root.parentElement === hero) return;
40+
if (!hero) return;
41+
42+
heroRoot = hero;
43+
hero.dataset.workflowHeroMounted = 'true';
44+
if (root.parentElement === hero) return;
3845

3946
hero.append(root);
4047
root.classList.add('workflow-hero--mounted');
4148
}
4249

50+
function unmountFromHero() {
51+
stopCarousel();
52+
root.remove();
53+
heroRoot?.removeAttribute('data-workflow-hero-mounted');
54+
}
55+
4356
mountIntoHero();
4457

4558
/** @type {HTMLElement | null} */
@@ -131,7 +144,7 @@ const deck = {
131144
startCarousel();
132145
} catch (error) {
133146
console.error('Failed to load PDF slides', error);
134-
if (loading) loading.textContent = 'Unable to load slides';
147+
unmountFromHero();
135148
}
136149
}
137150

@@ -247,7 +260,7 @@ const deck = {
247260
}
248261

249262
@media (min-width: 50rem) {
250-
:global(.hero) {
263+
:global(.hero[data-workflow-hero-mounted='true']) {
251264
grid-template-columns: minmax(0, 7fr) minmax(0, 13fr);
252265
align-items: center;
253266
gap: 1.5rem;

docs/tests/slide-preview.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@ test.describe('Slide Preview on Homepage', () => {
122122
// Wait a bit for the error to be displayed
123123
await page.waitForTimeout(2000);
124124

125-
// Verify error message is displayed
126-
const loading = page.locator('[data-slide-loading]');
127-
const errorText = await loading.textContent();
128-
expect(errorText).toContain('Unable to load slides');
125+
// Verify the slide preview is removed so the default hero layout remains.
126+
const slideHero = page.locator('[data-slide-hero]');
127+
await expect(slideHero).toHaveCount(0);
128+
129+
const hero = page.locator('.hero');
130+
await expect(hero).not.toHaveAttribute('data-workflow-hero-mounted', 'true');
129131
});
130132
});

0 commit comments

Comments
 (0)