remarkCollectImages() — astro Function Reference
Architecture documentation for the remarkCollectImages() function in remark-collect-images.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD fce11875_93ff_c513_496c_df23478a2fd4["remarkCollectImages()"] 4b71d521_90eb_5c80_622a_45eb4293c988["remark-collect-images.ts"] fce11875_93ff_c513_496c_df23478a2fd4 -->|defined in| 4b71d521_90eb_5c80_622a_45eb4293c988 style fce11875_93ff_c513_496c_df23478a2fd4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/markdown/remark/src/remark-collect-images.ts lines 8–48
export function remarkCollectImages(opts: AstroMarkdownProcessorOptions['image']) {
const domains = opts?.domains ?? [];
const remotePatterns = opts?.remotePatterns ?? [];
return function (tree: Root, vfile: VFile) {
if (typeof vfile?.path !== 'string') return;
const definition = definitions(tree);
const localImagePaths = new Set<string>();
const remoteImagePaths = new Set<string>();
visit(tree, (node) => {
let url: string | undefined;
if (node.type === 'image') {
url = decodeURI(node.url);
} else if (node.type === 'imageReference') {
const imageDefinition = definition(node.identifier);
if (imageDefinition) {
url = decodeURI(imageDefinition.url);
}
}
if (!url) return;
if (URL.canParse(url)) {
if (isRemoteAllowed(url, { domains, remotePatterns })) {
remoteImagePaths.add(url);
}
} else if (!url.startsWith('/')) {
// If:
// + not a valid URL
// + AND not an absolute path
// Then it's a local image.
localImagePaths.add(url);
}
});
vfile.data.astro ??= {};
vfile.data.astro.localImagePaths = Array.from(localImagePaths);
vfile.data.astro.remoteImagePaths = Array.from(remoteImagePaths);
};
}
Domain
Subdomains
Source
Frequently Asked Questions
What does remarkCollectImages() do?
remarkCollectImages() is a function in the astro codebase, defined in packages/markdown/remark/src/remark-collect-images.ts.
Where is remarkCollectImages() defined?
remarkCollectImages() is defined in packages/markdown/remark/src/remark-collect-images.ts at line 8.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free