getRehypePlugins() — astro Function Reference
Architecture documentation for the getRehypePlugins() function in plugins.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 54d12754_919b_fe84_dc9c_2d1ec1efe916["getRehypePlugins()"] d7312c7b_f89c_b923_6191_574b373e0444["plugins.ts"] 54d12754_919b_fe84_dc9c_2d1ec1efe916 -->|defined in| d7312c7b_f89c_b923_6191_574b373e0444 0dc520d4_0cd7_875c_4c70_cfd7a63069bf["createMdxProcessor()"] 0dc520d4_0cd7_875c_4c70_cfd7a63069bf -->|calls| 54d12754_919b_fe84_dc9c_2d1ec1efe916 style 54d12754_919b_fe84_dc9c_2d1ec1efe916 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/integrations/mdx/src/plugins.ts lines 60–104
function getRehypePlugins(mdxOptions: MdxOptions): PluggableList {
let rehypePlugins: PluggableList = [
// ensure `data.meta` is preserved in `properties.metastring` for rehype syntax highlighters
rehypeMetaString,
// rehypeRaw allows custom syntax highlighters to work without added config
[rehypeRaw, { passThrough: nodeTypes }],
];
const syntaxHighlight = mdxOptions.syntaxHighlight;
if (syntaxHighlight && !isPerformanceBenchmark) {
const syntaxHighlightType =
typeof syntaxHighlight === 'string' ? syntaxHighlight : syntaxHighlight?.type;
const excludeLangs =
typeof syntaxHighlight === 'object' ? syntaxHighlight?.excludeLangs : undefined;
// Apply syntax highlighters after user plugins to match `markdown/remark` behavior
if (syntaxHighlightType === 'shiki') {
rehypePlugins.push([rehypeShiki, mdxOptions.shikiConfig, excludeLangs]);
} else if (syntaxHighlightType === 'prism') {
rehypePlugins.push([rehypePrism, excludeLangs]);
}
}
rehypePlugins.push(...mdxOptions.rehypePlugins, rehypeImageToComponent);
if (!isPerformanceBenchmark) {
// getHeadings() is guaranteed by TS, so this must be included.
// We run `rehypeHeadingIds` _last_ to respect any custom IDs set by user plugins.
rehypePlugins.push([rehypeHeadingIds], rehypeInjectHeadingsExport);
}
rehypePlugins.push(
// Render info from `vfile.data.astro.frontmatter` as JS
rehypeApplyFrontmatterExport,
// Analyze MDX nodes and attach to `vfile.data.__astroMetadata`
rehypeAnalyzeAstroMetadata,
);
if (mdxOptions.optimize) {
// Convert user `optimize` option to compatible `rehypeOptimizeStatic` option
const options = mdxOptions.optimize === true ? undefined : mdxOptions.optimize;
rehypePlugins.push([rehypeOptimizeStatic, options]);
}
return rehypePlugins;
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does getRehypePlugins() do?
getRehypePlugins() is a function in the astro codebase, defined in packages/integrations/mdx/src/plugins.ts.
Where is getRehypePlugins() defined?
getRehypePlugins() is defined in packages/integrations/mdx/src/plugins.ts at line 60.
What calls getRehypePlugins()?
getRehypePlugins() is called by 1 function(s): createMdxProcessor.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free