glob.ts — astro Source File
Architecture documentation for glob.ts, a typescript file in the astro codebase. 11 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 6e7c310e_d293_0d26_5ed9_d09724209fd3["glob.ts"] 7f07e12d_4af0_1918_f31b_31410b415993["../types/public/content.js"] 6e7c310e_d293_0d26_5ed9_d09724209fd3 --> 7f07e12d_4af0_1918_f31b_31410b415993 b1ad5044_5dee_93fa_9942_3365c09d93c8["../../content/data-store.js"] 6e7c310e_d293_0d26_5ed9_d09724209fd3 --> b1ad5044_5dee_93fa_9942_3365c09d93c8 520c567a_b741_f105_70ac_c637eacc7f83["../content/utils.js"] 6e7c310e_d293_0d26_5ed9_d09724209fd3 --> 520c567a_b741_f105_70ac_c637eacc7f83 a7935420_ff38_d53d_2988_e0293e03591e["./loaders/types.js"] 6e7c310e_d293_0d26_5ed9_d09724209fd3 --> a7935420_ff38_d53d_2988_e0293e03591e e16a223b_37f3_6b25_1ee1_2b7bcb9d9415["node:fs"] 6e7c310e_d293_0d26_5ed9_d09724209fd3 --> e16a223b_37f3_6b25_1ee1_2b7bcb9d9415 c52a5f83_66e3_37d7_9ebb_767f7129bc62["node:path"] 6e7c310e_d293_0d26_5ed9_d09724209fd3 --> c52a5f83_66e3_37d7_9ebb_767f7129bc62 d9a92db9_c95e_9165_13ac_24b3d859d946["node:url"] 6e7c310e_d293_0d26_5ed9_d09724209fd3 --> d9a92db9_c95e_9165_13ac_24b3d859d946 2a508d35_5271_6ab9_1ae5_ced1613f7e29["p-limit"] 6e7c310e_d293_0d26_5ed9_d09724209fd3 --> 2a508d35_5271_6ab9_1ae5_ced1613f7e29 10250468_0e83_bd69_43e9_3bcef2294a91["piccolore"] 6e7c310e_d293_0d26_5ed9_d09724209fd3 --> 10250468_0e83_bd69_43e9_3bcef2294a91 d0400f4e_b2b2_3254_3d6b_e70ab2075b1d["picomatch"] 6e7c310e_d293_0d26_5ed9_d09724209fd3 --> d0400f4e_b2b2_3254_3d6b_e70ab2075b1d e64464d4_88a4_c7e2_f90f_758b06231bbe["tinyglobby"] 6e7c310e_d293_0d26_5ed9_d09724209fd3 --> e64464d4_88a4_c7e2_f90f_758b06231bbe style 6e7c310e_d293_0d26_5ed9_d09724209fd3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { existsSync, promises as fs } from 'node:fs';
import { relative } from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import pLimit from 'p-limit';
import colors from 'piccolore';
import picomatch from 'picomatch';
import { glob as tinyglobby } from 'tinyglobby';
import type { ContentEntryRenderFunction, ContentEntryType } from '../../types/public/content.js';
import type { RenderedContent } from '../data-store.js';
import { getContentEntryIdAndSlug, posixRelative } from '../utils.js';
import type { Loader } from './types.js';
interface GenerateIdOptions {
/** The path to the entry file, relative to the base directory. */
entry: string;
/** The base directory URL. */
base: URL;
/** The parsed, unvalidated data of the entry. */
data: Record<string, unknown>;
}
interface GlobOptions {
/** The glob pattern to match files, relative to the base directory */
pattern: string | Array<string>;
/** The base directory to resolve the glob pattern from. Relative to the root directory, or an absolute file URL. Defaults to `.` */
base?: string | URL;
/**
* Function that generates an ID for an entry. Default implementation generates a slug from the entry path.
* @returns The ID of the entry. Must be unique per collection.
**/
generateId?: (options: GenerateIdOptions) => string;
/**
* Retains the unparsed body of the file in the data store, in addition to the rendered HTML.
* If `false`, `entry.body` will be undefined if the content type has a parser.
* Defaults to `true`.
*/
retainBody?: boolean;
}
function generateIdDefault({ entry, base, data }: GenerateIdOptions, isLegacy?: boolean): string {
if (data.slug) {
return data.slug as string;
}
const entryURL = new URL(encodeURI(entry), base);
if (isLegacy) {
// Legacy behavior: use ID based on path, not slug
const { id } = getContentEntryIdAndSlug({
entry: entryURL,
contentDir: base,
collection: '',
});
return id;
}
const { slug } = getContentEntryIdAndSlug({
entry: entryURL,
contentDir: base,
collection: '',
});
return slug;
// ... (313 more lines)
Domain
Subdomains
Dependencies
- ../../content/data-store.js
- ../content/utils.js
- ../types/public/content.js
- ./loaders/types.js
- node:fs
- node:path
- node:url
- p-limit
- piccolore
- picomatch
- tinyglobby
Source
Frequently Asked Questions
What does glob.ts do?
glob.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 glob.ts?
glob.ts defines 4 function(s): checkPrefix, generateIdDefault, glob, options.
What does glob.ts depend on?
glob.ts imports 11 module(s): ../../content/data-store.js, ../content/utils.js, ../types/public/content.js, ./loaders/types.js, node:fs, node:path, node:url, p-limit, and 3 more.
Where is glob.ts in the architecture?
glob.ts is located at packages/astro/src/content/loaders/glob.ts (domain: ContentCollections, subdomain: DataLoaders, directory: packages/astro/src/content/loaders).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free