4.6 KiB
4.6 KiB
<img> tags were processed by Vue before static asset resolution\n2. Vite's import analyzer treated image paths as module imports\n3. The ?url query parameter didn't prevent Vue module processing\n4. Markdown image syntax also failed due to path resolution order\n\n## Root Cause Analysis\n\nWhen presentations were in versions/ subdirectory:\n\n- Relative paths like ./sections/ and ../sections/ created path resolution conflicts\n- Vue component compilation happened before static asset path resolution\n- Vite tried to import images as ES modules before they could be served as static assets\n\n## Final Solution (Working)\n\n### 1. Import Images as Vue Modules\n\nAdded <script setup> block to all presentations and sections:\n\nvue\n<script setup>\nimport logoImg from '/images/provisioning-logo.svg?url'\n</script>\n\n\nThen use the imported variable in the template:\n\nhtml\n<img :src="logoImg" alt="Provisioning Logo" class="w-32 mx-auto mt-8" />\n\n\n### 2. Copy Presentation to Root Before Execution\n\nUpdated run.nu script to:\n\n1. Copy presentation file from versions/ to root\n2. Execute pnpm run dev with the copied file\n3. Clean up (delete) the copied file after server stops\n\nnushell\n# Copy presentation to root\ncp $"versions/($selected.name)" $selected.name\n\n# Execute from root\npnpm run dev $selected.name\n\n# Cleanup\nrm $selected.name\n\n\n### 3. Update Section Paths\n\nChanged all src: directives from ./sections/ to ../sections/:\n\nBefore:\n\nmarkdown\n---\nsrc: ./sections/01-intro.md\n---\n\n\nAfter:\n\nmarkdown\n---\nsrc: ../sections/01-intro.md\n---\n\n\nThis works because:\n\n- Presentation copied to root\n- Root has sections/ directory at same level\n- Path ../sections/ goes up one level to root, then into sections/\n\n## Files Modified\n\n### Script\n\n- ✅ run.nu - Added copy/cleanup logic\n\n### Presentations (5 files)\n\n- ✅ versions/pitch.md - Import script + src paths\n- ✅ versions/demo-intro.md - Import script + src paths \n- ✅ versions/talk.md - Import script + src paths\n- ✅ versions/full.md - Import script + src paths\n- ✅ versions/workshop.md - Import script + src paths\n\n### Sections (2 files with images)\n\n- ✅ sections/01-intro.md - Import script + vue image binding\n- ✅ sections/07-conclusion.md - Import script + vue image binding\n\n### Configuration\n\n- ✅ slidev.config.ts - Added public directory configuration\n\n## How It Works Now\n\nplaintext\nUser selects presentation\n ↓\nrun.nu copies file from versions/ to root\n ↓\npnpm run dev executes with file in root\n ↓\nSlidev processes presentation\n ↓\nScript setup imports SVG as module URL\n ↓\nTemplate uses :src binding for image\n ↓\nVue renders with proper static asset path\n ↓\nBrowser loads /images/provisioning-logo.svg\n ↓\nServer stops → Temporary file cleaned up\n\n\n## Why This Works\n\n1. Vue Module Import: By importing the image in script setup, Vite processes it as a proper module import with ?url, which returns the static asset path\n\n2. Root Execution: Copying to root eliminates path resolution confusion - all relative paths are from the root level\n\n3. Proper Path Resolution: With presentations at root and sections at sections/, the ../sections/ path is correct and unambiguous\n\n4. Standard Slidev Pattern: This follows Slidev's recommended approach for handling static assets in presentations\n\n## Testing\n\nRun presentations with:\n\nbash\nnu run.nu\n\n\nSelect any presentation and verify:\n\n- ✅ No build errors\n- ✅ No "import-analysis" plugin errors \n- ✅ Logo displays on all slides\n- ✅ All sections load correctly\n- ✅ Temporary file cleaned up after execution\n\n## Key Insights\n\n1. Avoid Direct Image Tags: Never use <img src="..."> in Slidev - always import and bind\n2. Copy to Root: When using modular files, copying to root simplifies path resolution\n3. Vue Bindings: Use :src="variable" instead of src="string" for dynamic paths\n4. Proper Imports: Import static assets with ?url to get the resolved URL string\n\n## Production Readiness\n\n✅ All Issues Resolved\n\n- No Vite import errors\n- No build failures\n- All presentations functional\n- Clean up after execution\n- Ready for consulting engagement\n\n---\nSolution Date: 2025-11-14\nStatus: ✅ PRODUCTION READY\nBuild Status: ✅ ERROR FREE