Home / File/ content-layer.ts — astro Source File

content-layer.ts — astro Source File

Architecture documentation for content-layer.ts, a typescript file in the astro codebase. 16 imports, 0 dependents.

File typescript ContentCollections DataLoaders 16 imports 4 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  3460caba_c22e_57de_8fed_316b77465ef7["content-layer.ts"]
  ef8a1e3f_e350_75a6_b92d_62a8566d8db9["../core/errors/index.js"]
  3460caba_c22e_57de_8fed_316b77465ef7 --> ef8a1e3f_e350_75a6_b92d_62a8566d8db9
  d3861967_b647_84d2_ff48_15013353bd56["../core/logger/core.js"]
  3460caba_c22e_57de_8fed_316b77465ef7 --> d3861967_b647_84d2_ff48_15013353bd56
  e9b74c5a_8d34_34a7_e196_5e41b87214aa["../types/astro.js"]
  3460caba_c22e_57de_8fed_316b77465ef7 --> e9b74c5a_8d34_34a7_e196_5e41b87214aa
  7f07e12d_4af0_1918_f31b_31410b415993["../types/public/content.js"]
  3460caba_c22e_57de_8fed_316b77465ef7 --> 7f07e12d_4af0_1918_f31b_31410b415993
  eb7ca709_080c_a438_b9d7_f1238835779d["../content/consts.js"]
  3460caba_c22e_57de_8fed_316b77465ef7 --> eb7ca709_080c_a438_b9d7_f1238835779d
  b1ad5044_5dee_93fa_9942_3365c09d93c8["../../content/data-store.js"]
  3460caba_c22e_57de_8fed_316b77465ef7 --> b1ad5044_5dee_93fa_9942_3365c09d93c8
  a7935420_ff38_d53d_2988_e0293e03591e["./loaders/types.js"]
  3460caba_c22e_57de_8fed_316b77465ef7 --> a7935420_ff38_d53d_2988_e0293e03591e
  f0d8d494_c471_39a6_5e1f_0ed356c4f6d8["../../content/mutable-data-store.js"]
  3460caba_c22e_57de_8fed_316b77465ef7 --> f0d8d494_c471_39a6_5e1f_0ed356c4f6d8
  520c567a_b741_f105_70ac_c637eacc7f83["../content/utils.js"]
  3460caba_c22e_57de_8fed_316b77465ef7 --> 520c567a_b741_f105_70ac_c637eacc7f83
  4bed3921_7b34_5d94_8ee6_49b18c837886["./watcher.js"]
  3460caba_c22e_57de_8fed_316b77465ef7 --> 4bed3921_7b34_5d94_8ee6_49b18c837886
  e16a223b_37f3_6b25_1ee1_2b7bcb9d9415["node:fs"]
  3460caba_c22e_57de_8fed_316b77465ef7 --> e16a223b_37f3_6b25_1ee1_2b7bcb9d9415
  82f345a2_2234_43f1_c3c4_eea191acdca8["markdown-remark"]
  3460caba_c22e_57de_8fed_316b77465ef7 --> 82f345a2_2234_43f1_c3c4_eea191acdca8
  c66a1462_47a2_74f6_75e3_f392c457f4a0["p-queue"]
  3460caba_c22e_57de_8fed_316b77465ef7 --> c66a1462_47a2_74f6_75e3_f392c457f4a0
  263e522e_1aa5_ebc3_e7d6_45ebc51671f7["vite"]
  3460caba_c22e_57de_8fed_316b77465ef7 --> 263e522e_1aa5_ebc3_e7d6_45ebc51671f7
  style 3460caba_c22e_57de_8fed_316b77465ef7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { existsSync, promises as fs } from 'node:fs';
import {
	createMarkdownProcessor,
	parseFrontmatter,
	type MarkdownProcessor,
} from '@astrojs/markdown-remark';
import PQueue from 'p-queue';
import type { FSWatcher } from 'vite';
import xxhash from 'xxhash-wasm';
import type * as z from 'zod/v4';
import { AstroError, AstroErrorData } from '../core/errors/index.js';
import type { Logger } from '../core/logger/core.js';
import type { AstroSettings } from '../types/astro.js';
import type { ContentEntryType, RefreshContentOptions } from '../types/public/content.js';
import {
	ASSET_IMPORTS_FILE,
	COLLECTIONS_MANIFEST_FILE,
	CONTENT_LAYER_TYPE,
	DATA_STORE_FILE,
	MODULES_IMPORTS_FILE,
} from './consts.js';
import type { RenderedContent } from './data-store.js';
import type { LoaderContext, RenderMarkdownOptions } from './loaders/types.js';
import type { MutableDataStore } from './mutable-data-store.js';
import {
	type ContentObservable,
	getEntryConfigByExtMap,
	getEntryData,
	globalContentConfigObserver,
	loaderReturnSchema,
	safeStringify,
} from './utils.js';
import { createWatcherWrapper, type WrappedWatcher } from './watcher.js';

interface ContentLayerOptions {
	store: MutableDataStore;
	settings: AstroSettings;
	logger: Logger;
	watcher?: FSWatcher;
}

type CollectionLoader<TData> = () =>
	| Array<TData>
	| Promise<Array<TData>>
	| Record<string, Record<string, unknown>>
	| Promise<Record<string, Record<string, unknown>>>;

class ContentLayer {
	#logger: Logger;
	#store: MutableDataStore;
	#settings: AstroSettings;
	#watcher?: WrappedWatcher;
	#lastConfigDigest?: string;
	#unsubscribe?: () => void;
	#markdownProcessor?: MarkdownProcessor;
	#generateDigest?: (data: Record<string, unknown> | string) => string;

	#queue: PQueue;

	constructor({ settings, logger, store, watcher }: ContentLayerOptions) {
// ... (420 more lines)

Subdomains

Classes

Dependencies

  • ../../content/data-store.js
  • ../../content/mutable-data-store.js
  • ../content/consts.js
  • ../content/utils.js
  • ../core/errors/index.js
  • ../core/logger/core.js
  • ../types/astro.js
  • ../types/public/content.js
  • ./loaders/types.js
  • ./watcher.js
  • markdown-remark
  • node:fs
  • p-queue
  • v4
  • vite
  • xxhash-wasm

Frequently Asked Questions

What does content-layer.ts do?
content-layer.ts is a source file in the astro codebase, written in typescript. It belongs to the ContentCollections domain, DataLoaders subdomain.
What functions are defined in content-layer.ts?
content-layer.ts defines 4 function(s): Array, contentLayerSingleton, getDataStoreFile, simpleLoader.
What does content-layer.ts depend on?
content-layer.ts imports 16 module(s): ../../content/data-store.js, ../../content/mutable-data-store.js, ../content/consts.js, ../content/utils.js, ../core/errors/index.js, ../core/logger/core.js, ../types/astro.js, ../types/public/content.js, and 8 more.
Where is content-layer.ts in the architecture?
content-layer.ts is located at packages/astro/src/content/content-layer.ts (domain: ContentCollections, subdomain: DataLoaders, directory: packages/astro/src/content).

Analyze Your Own Codebase

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

Try Supermodel Free