Home / File/ index.ts — astro Source File

index.ts — astro Source File

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

File typescript CoreAstro RoutingSystem 10 imports 6 functions

Entity Profile

Dependency Diagram

graph LR
  4dbca764_76ba_1a5b_79ab_f6ddff0cb420["index.ts"]
  266ec0d4_2199_989b_a8ff_c5a6cade5325["./rehype-optimize-static.js"]
  4dbca764_76ba_1a5b_79ab_f6ddff0cb420 --> 266ec0d4_2199_989b_a8ff_c5a6cade5325
  ab5f9b39_abc6_0697_d4ba_c51748add5b2["./utils.js"]
  4dbca764_76ba_1a5b_79ab_f6ddff0cb420 --> ab5f9b39_abc6_0697_d4ba_c51748add5b2
  685e670e_daeb_300e_3337_a61e20d20e1f["./vite-plugin-mdx.js"]
  4dbca764_76ba_1a5b_79ab_f6ddff0cb420 --> 685e670e_daeb_300e_3337_a61e20d20e1f
  bb28144e_8f40_2798_9191_6756f53398b6["./vite-plugin-mdx-postprocess.js"]
  4dbca764_76ba_1a5b_79ab_f6ddff0cb420 --> bb28144e_8f40_2798_9191_6756f53398b6
  5d6d1861_a18d_b246_cd94_08889ab7e74c["promises"]
  4dbca764_76ba_1a5b_79ab_f6ddff0cb420 --> 5d6d1861_a18d_b246_cd94_08889ab7e74c
  d9a92db9_c95e_9165_13ac_24b3d859d946["node:url"]
  4dbca764_76ba_1a5b_79ab_f6ddff0cb420 --> d9a92db9_c95e_9165_13ac_24b3d859d946
  82f345a2_2234_43f1_c3c4_eea191acdca8["markdown-remark"]
  4dbca764_76ba_1a5b_79ab_f6ddff0cb420 --> 82f345a2_2234_43f1_c3c4_eea191acdca8
  f16d8c76_2866_6150_bd14_0347b59abfe9["astro"]
  4dbca764_76ba_1a5b_79ab_f6ddff0cb420 --> f16d8c76_2866_6150_bd14_0347b59abfe9
  b5eedb63_b659_9ab6_0741_b5822edde660["remark-rehype"]
  4dbca764_76ba_1a5b_79ab_f6ddff0cb420 --> b5eedb63_b659_9ab6_0741_b5822edde660
  54ce55cc_9dc1_4ebd_28dd_358c1e22d4e7["unified"]
  4dbca764_76ba_1a5b_79ab_f6ddff0cb420 --> 54ce55cc_9dc1_4ebd_28dd_358c1e22d4e7
  style 4dbca764_76ba_1a5b_79ab_f6ddff0cb420 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import fs from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
import { markdownConfigDefaults } from '@astrojs/markdown-remark';
import type {
	AstroIntegration,
	AstroIntegrationLogger,
	AstroRenderer,
	ContentEntryType,
	HookParameters,
} from 'astro';
import type { Options as RemarkRehypeOptions } from 'remark-rehype';
import type { PluggableList } from 'unified';
import type { OptimizeOptions } from './rehype-optimize-static.js';
import { ignoreStringPlugins, safeParseFrontmatter } from './utils.js';
import { type VitePluginMdxOptions, vitePluginMdx } from './vite-plugin-mdx.js';
import { vitePluginMdxPostprocess } from './vite-plugin-mdx-postprocess.js';

export type MdxOptions = Omit<typeof markdownConfigDefaults, 'remarkPlugins' | 'rehypePlugins'> & {
	extendMarkdownConfig: boolean;
	recmaPlugins: PluggableList;
	// Markdown allows strings as remark and rehype plugins.
	// This is not supported by the MDX compiler, so override types here.
	remarkPlugins: PluggableList;
	rehypePlugins: PluggableList;
	remarkRehype: RemarkRehypeOptions;
	optimize: boolean | OptimizeOptions;
};

type SetupHookParams = HookParameters<'astro:config:setup'> & {
	// `addPageExtension` and `contentEntryType` are not a public APIs
	// Add type defs here
	addPageExtension: (extension: string) => void;
	addContentEntryType: (contentEntryType: ContentEntryType) => void;
};

export function getContainerRenderer(): AstroRenderer {
	return {
		name: 'astro:jsx',
		serverEntrypoint: '@astrojs/mdx/server.js',
	};
}

export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): AstroIntegration {
	// @ts-expect-error Temporarily assign an empty object here, which will be re-assigned by the
	// `astro:config:done` hook later. This is so that `vitePluginMdx` can get hold of a reference earlier.
	let vitePluginMdxOptions: VitePluginMdxOptions = {};

	return {
		name: '@astrojs/mdx',
		hooks: {
			'astro:config:setup': async (params) => {
				const { updateConfig, config, addPageExtension, addContentEntryType, addRenderer } =
					params as SetupHookParams;

				addRenderer({
					name: 'astro:jsx',
					serverEntrypoint: new URL('../dist/server.js', import.meta.url),
				});
				addPageExtension('.mdx');
				addContentEntryType({
// ... (92 more lines)

Domain

Subdomains

Dependencies

  • ./rehype-optimize-static.js
  • ./utils.js
  • ./vite-plugin-mdx-postprocess.js
  • ./vite-plugin-mdx.js
  • astro
  • markdown-remark
  • node:url
  • promises
  • remark-rehype
  • unified

Frequently Asked Questions

What does index.ts do?
index.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RoutingSystem subdomain.
What functions are defined in index.ts?
index.ts defines 6 function(s): applyDefaultOptions, contentEntryType, extension, getContainerRenderer, markdownConfigToMdxOptions, mdx.
What does index.ts depend on?
index.ts imports 10 module(s): ./rehype-optimize-static.js, ./utils.js, ./vite-plugin-mdx-postprocess.js, ./vite-plugin-mdx.js, astro, markdown-remark, node:url, promises, and 2 more.
Where is index.ts in the architecture?
index.ts is located at packages/integrations/mdx/src/index.ts (domain: CoreAstro, subdomain: RoutingSystem, directory: packages/integrations/mdx/src).

Analyze Your Own Codebase

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

Try Supermodel Free