MCPcopy
hub / github.com/TheOrcDev/8bitcn-ui / getTextContent

Function getTextContent

mdx-components.tsx:228–245  ·  view source on GitHub ↗
(node: ReactNode)

Source from the content-addressed store, hash-verified

226
227 // Extract text content from React children if __raw__ is not available
228 const getTextContent = (node: ReactNode): string => {
229 if (typeof node === "string") {
230 return node;
231 }
232 if (typeof node === "number") {
233 return String(node);
234 }
235 if (Array.isArray(node)) {
236 return node.map(getTextContent).join("");
237 }
238 if (isValidElement(node)) {
239 const nodeProps = node.props as { children?: ReactNode };
240 if (nodeProps.children) {
241 return getTextContent(nodeProps.children);
242 }
243 }
244 return "";
245 };
246
247 const codeContent = __raw__ || getTextContent(children);
248

Callers 1

mdx-components.tsxFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected