MCPcopy Create free account
hub / github.com/adobe/react-spectrum / extractLabel

Function extractLabel

packages/dev/s2-docs/scripts/generateMarkdownDocs.mjs:2555–2570  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2553 const newNodes = [];
2554
2555 const extractLabel = itemNode => {
2556 const labelAttr = itemNode.attributes?.find(a => a.name === 'label');
2557 if (!labelAttr) {
2558 return null;
2559 }
2560
2561 if (labelAttr.value?.type === 'mdxJsxAttributeValueExpression') {
2562 return labelAttr.value.value.replace(/['"`]/g, '').trim();
2563 }
2564
2565 if (typeof labelAttr.value === 'string') {
2566 return labelAttr.value.trim();
2567 }
2568
2569 return null;
2570 };
2571
2572 bundlerItems.forEach(itemNode => {
2573 const label = extractLabel(itemNode) || 'Configuration';

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected