rehypeApplyFrontmatterExport() — astro Function Reference
Architecture documentation for the rehypeApplyFrontmatterExport() function in rehype-apply-frontmatter-export.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 3cb2c0d6_fe6a_7406_95ac_85f24f55edc1["rehypeApplyFrontmatterExport()"] 50f0dfd4_d9b5_8cd5_80a6_3519a94ab6d7["rehype-apply-frontmatter-export.ts"] 3cb2c0d6_fe6a_7406_95ac_85f24f55edc1 -->|defined in| 50f0dfd4_d9b5_8cd5_80a6_3519a94ab6d7 e5738373_9d28_407c_3733_9fa1b3abbc0b["shouldAddCharset()"] 3cb2c0d6_fe6a_7406_95ac_85f24f55edc1 -->|calls| e5738373_9d28_407c_3733_9fa1b3abbc0b style 3cb2c0d6_fe6a_7406_95ac_85f24f55edc1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/integrations/mdx/src/rehype-apply-frontmatter-export.ts lines 19–72
export function rehypeApplyFrontmatterExport() {
return function (tree: Root, vfile: VFile) {
const frontmatter = vfile.data.astro?.frontmatter;
if (!frontmatter || !isFrontmatterValid(frontmatter))
throw new Error(
// Copied from Astro core `errors-data`
// TODO: find way to import error data from core
'[MDX] A remark or rehype plugin attempted to inject invalid frontmatter. Ensure "astro.frontmatter" is set to a valid JSON object that is not `null` or `undefined`.',
);
const extraChildren: RootContent[] = [
jsToTreeNode(`export const frontmatter = ${JSON.stringify(frontmatter)};`),
];
if (frontmatter.layout) {
extraChildren.unshift(
jsToTreeNode(
// NOTE: Use `__astro_*` import names to prevent conflicts with user code
/** @see 'vite-plugin-markdown' for layout props reference */
`\
import { jsx as __astro_layout_jsx__ } from 'astro/jsx-runtime';
import __astro_layout_component__ from ${JSON.stringify(frontmatter.layout)};
export default function ({ children }) {
const { layout, ...content } = frontmatter;
content.file = file;
content.url = url;
return __astro_layout_jsx__(__astro_layout_component__, {
file,
url,
content,
frontmatter: content,
headings: getHeadings(),
'server:root': true,
children,
});
};`,
),
);
} else if (shouldAddCharset(tree, vfile)) {
extraChildren.unshift({
type: 'mdxJsxFlowElement',
name: 'meta',
attributes: [
{
type: 'mdxJsxAttribute',
name: 'charset',
value: 'utf-8',
},
],
children: [],
});
}
tree.children = extraChildren.concat(tree.children);
};
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does rehypeApplyFrontmatterExport() do?
rehypeApplyFrontmatterExport() is a function in the astro codebase, defined in packages/integrations/mdx/src/rehype-apply-frontmatter-export.ts.
Where is rehypeApplyFrontmatterExport() defined?
rehypeApplyFrontmatterExport() is defined in packages/integrations/mdx/src/rehype-apply-frontmatter-export.ts at line 19.
What does rehypeApplyFrontmatterExport() call?
rehypeApplyFrontmatterExport() calls 1 function(s): shouldAddCharset.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free