Migrate Images Skill
This skill scans all Markdown files in the src/content/docs folder and downloads external, relative, or site-hosted images locally to the src/assets folder. It then automatically computes and rewrites the correct relative image links inside the markdown files.
When to Use
Use this skill whenever:
- You copy or import posts from a remote site (e.g.
rodydavis.com) that reference hosted images. - You want to bundle all images locally within the Astro codebase to support optimized builds and offline operation.
- Image assets need to be cleanly categorized under Astro's
src/assets/folder.
How it Works
The under-the-hood script:
- Recursively walks all
.mdfiles insrc/content/docs. - Uses Regex to extract image reference matches
. - Skips external HTTP/HTTPS absolute links unless they match the source website base domain (
https://rodydavis.com). - Downloads remote/relative images using
fetchand pipelines them tosrc/assetsusing sanitized safe filenames. - Calculates the relative path from the Markdown file to the localized image in
src/assetsand replaces the old reference in-place.
Execution
Run this command from the project root:
node .agents/skills/migrate-images/scripts/migrate-images.js