Home / Function/ getSymlinkedContentCollections() — astro Function Reference

getSymlinkedContentCollections() — astro Function Reference

Architecture documentation for the getSymlinkedContentCollections() function in utils.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  5863ff23_1a97_5b6c_cae9_ced3acc1ea5d["getSymlinkedContentCollections()"]
  7a09e708_c090_71c0_8138_7343699b1865["utils.ts"]
  5863ff23_1a97_5b6c_cae9_ced3acc1ea5d -->|defined in| 7a09e708_c090_71c0_8138_7343699b1865
  style 5863ff23_1a97_5b6c_cae9_ced3acc1ea5d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/content/utils.ts lines 267–303

export async function getSymlinkedContentCollections({
	contentDir,
	logger,
	fs,
}: {
	contentDir: URL;
	logger: Logger;
	fs: typeof fsMod;
}): Promise<Map<string, string>> {
	const contentPaths = new Map<string, string>();
	const contentDirPath = fileURLToPath(contentDir);
	try {
		if (!fs.existsSync(contentDirPath) || !fs.lstatSync(contentDirPath).isDirectory()) {
			return contentPaths;
		}
	} catch {
		// Ignore if there isn't a valid content directory
		return contentPaths;
	}
	try {
		const contentDirEntries = await fs.promises.readdir(contentDir, { withFileTypes: true });
		for (const entry of contentDirEntries) {
			if (entry.isSymbolicLink()) {
				const entryPath = path.join(contentDirPath, entry.name);
				const realPath = await fs.promises.realpath(entryPath);
				contentPaths.set(normalizePath(realPath), entry.name);
			}
		}
	} catch (e) {
		logger.warn('content', `Error when reading content directory "${contentDir}"`);
		logger.debug('content', e);
		// If there's an error, return an empty map
		return new Map<string, string>();
	}

	return contentPaths;
}

Subdomains

Frequently Asked Questions

What does getSymlinkedContentCollections() do?
getSymlinkedContentCollections() is a function in the astro codebase, defined in packages/astro/src/content/utils.ts.
Where is getSymlinkedContentCollections() defined?
getSymlinkedContentCollections() is defined in packages/astro/src/content/utils.ts at line 267.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free