Home / Function/ attachContentServerListeners() — astro Function Reference

attachContentServerListeners() — astro Function Reference

Architecture documentation for the attachContentServerListeners() function in server-listeners.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  44989853_c4ad_381b_bd7c_3ddd04499756["attachContentServerListeners()"]
  ab9fccbb_2c60_cea9_6491_c0c755fcbd23["server-listeners.ts"]
  44989853_c4ad_381b_bd7c_3ddd04499756 -->|defined in| ab9fccbb_2c60_cea9_6491_c0c755fcbd23
  style 44989853_c4ad_381b_bd7c_3ddd04499756 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/content/server-listeners.ts lines 15–46

export async function attachContentServerListeners({
	viteServer,
	fs,
	logger,
	settings,
}: ContentServerListenerParams) {
	const contentGenerator = await createContentTypesGenerator({
		fs,
		settings,
		logger,
		viteServer,
		contentConfigObserver: globalContentConfigObserver,
	});
	await contentGenerator.init();
	logger.debug('content', 'Types generated');

	viteServer.watcher.on('add', (entry) => {
		contentGenerator.queueEvent({ name: 'add', entry });
	});
	viteServer.watcher.on('addDir', (entry) =>
		contentGenerator.queueEvent({ name: 'addDir', entry }),
	);
	viteServer.watcher.on('change', (entry) => {
		contentGenerator.queueEvent({ name: 'change', entry });
	});
	viteServer.watcher.on('unlink', (entry) => {
		contentGenerator.queueEvent({ name: 'unlink', entry });
	});
	viteServer.watcher.on('unlinkDir', (entry) =>
		contentGenerator.queueEvent({ name: 'unlinkDir', entry }),
	);
}

Subdomains

Frequently Asked Questions

What does attachContentServerListeners() do?
attachContentServerListeners() is a function in the astro codebase, defined in packages/astro/src/content/server-listeners.ts.
Where is attachContentServerListeners() defined?
attachContentServerListeners() is defined in packages/astro/src/content/server-listeners.ts at line 15.

Analyze Your Own Codebase

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

Try Supermodel Free