rehypeSlots() — astro Function Reference
Architecture documentation for the rehypeSlots() function in slots.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD d4ac14ff_364a_0e3f_9101_c64bc59aeb36["rehypeSlots()"] b284acc9_ccb3_1b9d_31cb_02b2e7dedc9d["slots.ts"] d4ac14ff_364a_0e3f_9101_c64bc59aeb36 -->|defined in| b284acc9_ccb3_1b9d_31cb_02b2e7dedc9d style d4ac14ff_364a_0e3f_9101_c64bc59aeb36 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/vite-plugin-html/transform/slots.ts lines 7–28
const rehypeSlots: Plugin<[{ s: MagicString }], Root> = ({ s }) => {
return (tree, file) => {
visit(tree, (node: Root | RootContent) => {
if (node.type === 'element' && node.tagName === 'slot') {
if (typeof node.properties?.['is:inline'] !== 'undefined') return;
const name = node.properties?.['name'] ?? 'default';
const start = node.position?.start.offset ?? 0;
const end = node.position?.end.offset ?? 0;
const first = node.children.at(0) ?? node;
const last = node.children.at(-1) ?? node;
const text = file.value
.slice(first.position?.start.offset ?? 0, last.position?.end.offset ?? 0)
.toString();
s.overwrite(
start,
end,
`\${${SLOT_PREFIX}["${name}"] ?? \`${escapeTemplateLiteralCharacters(text).trim()}\`}`,
);
}
});
};
};
Domain
Subdomains
Source
Frequently Asked Questions
What does rehypeSlots() do?
rehypeSlots() is a function in the astro codebase, defined in packages/astro/src/vite-plugin-html/transform/slots.ts.
Where is rehypeSlots() defined?
rehypeSlots() is defined in packages/astro/src/vite-plugin-html/transform/slots.ts at line 7.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free