Home / File/ utils.ts — astro Source File

utils.ts — astro Source File

Architecture documentation for utils.ts, a typescript file in the astro codebase. 22 imports, 0 dependents.

File typescript ContentCollections DataLoaders 22 imports 40 functions

Entity Profile

Dependency Diagram

graph LR
  7a09e708_c090_71c0_8138_7343699b1865["utils.ts"]
  ef8a1e3f_e350_75a6_b92d_62a8566d8db9["../core/errors/index.js"]
  7a09e708_c090_71c0_8138_7343699b1865 --> ef8a1e3f_e350_75a6_b92d_62a8566d8db9
  91e2aae7_9271_3bbb_4d0e_63fd50e547d0["./utils.js"]
  7a09e708_c090_71c0_8138_7343699b1865 --> 91e2aae7_9271_3bbb_4d0e_63fd50e547d0
  d3861967_b647_84d2_ff48_15013353bd56["../core/logger/core.js"]
  7a09e708_c090_71c0_8138_7343699b1865 --> d3861967_b647_84d2_ff48_15013353bd56
  7e4494c0_5563_4329_1bff_a84be66e1bc2["../core/path.js"]
  7a09e708_c090_71c0_8138_7343699b1865 --> 7e4494c0_5563_4329_1bff_a84be66e1bc2
  a370a45c_02f1_30de_445d_47ee08d095a2["../core/viteUtils.js"]
  7a09e708_c090_71c0_8138_7343699b1865 --> a370a45c_02f1_30de_445d_47ee08d095a2
  e9b74c5a_8d34_34a7_e196_5e41b87214aa["../types/astro.js"]
  7a09e708_c090_71c0_8138_7343699b1865 --> e9b74c5a_8d34_34a7_e196_5e41b87214aa
  c32d12e2_d85e_28c0_eea7_9b29629857e0["../types/public/config.js"]
  7a09e708_c090_71c0_8138_7343699b1865 --> c32d12e2_d85e_28c0_eea7_9b29629857e0
  7f07e12d_4af0_1918_f31b_31410b415993["../types/public/content.js"]
  7a09e708_c090_71c0_8138_7343699b1865 --> 7f07e12d_4af0_1918_f31b_31410b415993
  eb7ca709_080c_a438_b9d7_f1238835779d["../content/consts.js"]
  7a09e708_c090_71c0_8138_7343699b1865 --> eb7ca709_080c_a438_b9d7_f1238835779d
  7127edc6_a142_b34c_8566_09e1242a5b25["./loaders/glob.js"]
  7a09e708_c090_71c0_8138_7343699b1865 --> 7127edc6_a142_b34c_8566_09e1242a5b25
  a7935420_ff38_d53d_2988_e0293e03591e["./loaders/types.js"]
  7a09e708_c090_71c0_8138_7343699b1865 --> a7935420_ff38_d53d_2988_e0293e03591e
  d01107ba_552a_d2bb_8e3e_5561e545712b["./runtime-assets.js"]
  7a09e708_c090_71c0_8138_7343699b1865 --> d01107ba_552a_d2bb_8e3e_5561e545712b
  e16a223b_37f3_6b25_1ee1_2b7bcb9d9415["node:fs"]
  7a09e708_c090_71c0_8138_7343699b1865 --> e16a223b_37f3_6b25_1ee1_2b7bcb9d9415
  c52a5f83_66e3_37d7_9ebb_767f7129bc62["node:path"]
  7a09e708_c090_71c0_8138_7343699b1865 --> c52a5f83_66e3_37d7_9ebb_767f7129bc62
  style 7a09e708_c090_71c0_8138_7343699b1865 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import fsMod from 'node:fs';
import path from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { parseFrontmatter } from '@astrojs/markdown-remark';
import { slug as githubSlug } from 'github-slugger';
import colors from 'piccolore';
import type { PluginContext } from 'rollup';
import type { RunnableDevEnvironment } from 'vite';
import xxhash from 'xxhash-wasm';
import * as z from 'zod/v4';
import { AstroError, AstroErrorData, errorMap, MarkdownError } from '../core/errors/index.js';
import { isYAMLException } from '../core/errors/utils.js';
import type { Logger } from '../core/logger/core.js';
import { appendForwardSlash } from '../core/path.js';
import { normalizePath } from '../core/viteUtils.js';
import type { AstroSettings } from '../types/astro.js';
import type { AstroConfig } from '../types/public/config.js';
import type { ContentEntryType, DataEntryType } from '../types/public/content.js';
import {
	type CONTENT_FLAGS,
	CONTENT_LAYER_TYPE,
	CONTENT_MODULE_FLAG,
	DEFERRED_MODULE,
	IMAGE_IMPORT_PREFIX,
	LIVE_CONTENT_TYPE,
	PROPAGATED_ASSET_FLAG,
} from './consts.js';
import { glob, secretLegacyFlag } from './loaders/glob.js';
import type { LoaderContext } from './loaders/types.js';
import { createImage } from './runtime-assets.js';

const entryTypeSchema = z
	.object({
		id: z.string({
			error: 'Content entry `id` must be a string',
			// Default to empty string so we can validate properly in the loader
		}),
	})
	.passthrough();

export const loaderReturnSchema = z.union([
	z.array(entryTypeSchema),
	z.record(
		z.string(),
		z
			.object({
				id: z
					.string({
						error: 'Content entry `id` must be a string',
					})
					.optional(),
			})
			.passthrough(),
	),
]);

const collectionConfigParser = z.union([
	z.object({
		type: z.literal('content').optional(),
		schema: z.any().optional(),
// ... (848 more lines)

Subdomains

Dependencies

  • ../content/consts.js
  • ../core/errors/index.js
  • ../core/logger/core.js
  • ../core/path.js
  • ../core/viteUtils.js
  • ../types/astro.js
  • ../types/public/config.js
  • ../types/public/content.js
  • ./loaders/glob.js
  • ./loaders/types.js
  • ./runtime-assets.js
  • ./utils.js
  • github-slugger
  • markdown-remark
  • node:fs
  • node:path
  • node:url
  • piccolore
  • rollup
  • v4
  • vite
  • xxhash-wasm

Frequently Asked Questions

What does utils.ts do?
utils.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 utils.ts?
utils.ts defines 40 function(s): C, autogenerateCollections, contentModuleToId, contentObservable, ctx, fn, getContentEntryExts, getContentEntryIdAndSlug, getContentPaths, getContentPathsWithConfig, and 30 more.
What does utils.ts depend on?
utils.ts imports 22 module(s): ../content/consts.js, ../core/errors/index.js, ../core/logger/core.js, ../core/path.js, ../core/viteUtils.js, ../types/astro.js, ../types/public/config.js, ../types/public/content.js, and 14 more.
Where is utils.ts in the architecture?
utils.ts is located at packages/astro/src/content/utils.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