Skip to main content
Glama
vue_utils.ts1.29 kB
import { Slot, VNode, Comment, Fragment, DefineComponent } from "vue"; // helper for wrapping slot children in functional components export function getSlotChildren(slot: Slot | undefined): VNode[] { return unwrapChildren(slot?.() || []); } function unwrapChildren(rawChildren: VNode[]) { const children = [] as VNode[]; rawChildren.forEach((child) => { // components that are hidden via v-if end up as a Comment <!--v-if--> so we skip over them if (child.type === Comment) return; // if the child is a template with a v-for, we actually want to get all of its children if (child.type === Fragment) { children.push(...unwrapChildren(child.children as VNode[])); } else { children.push(child); } }); return children as VNode[]; } // functional component TS helper // use by setting props arg type // example: // `const FunctionalComponent = (props: FunctionalComponentPropsType<typeof propsDefinition>, ctx: any) => ...` // see https://github.com/johnsoncodehk/volar/issues/924 export type FunctionalComponentPropsType<T> = InstanceType< DefineComponent<T> >["$props"]; // TODO: get the right type - see same issue above... // eslint-disable-next-line @typescript-eslint/no-explicit-any export type FunctionalComponentContextArg = any;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/systeminit/si'

If you have feedback or need assistance with the MCP directory API, please join our Discord server