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

Function File

packages/dev/s2-docs/src/CodeBlock.tsx:275–292  ·  view source on GitHub ↗
({
  filename,
  maxLines,
  type
}: {
  filename: string;
  maxLines?: number;
  type?: 'vanilla' | 'tailwind' | 's2';
})

Source from the content-addressed store, hash-verified

273const readFile = cache((file: string) => fs.readFileSync(file, 'utf8'));
274
275export function File({
276 filename,
277 maxLines,
278 type
279}: {
280 filename: string;
281 maxLines?: number;
282 type?: 'vanilla' | 'tailwind' | 's2';
283}) {
284 let contents = readFile(path.resolve(baseDir, filename)).replace(STARTER_ALIAS_RE, './');
285 return (
286 <CodePlatter type={type}>
287 <TruncatedCode lang={path.extname(filename).slice(1)} hideImports={false} maxLines={maxLines}>
288 {contents}
289 </TruncatedCode>
290 </CodePlatter>
291 );
292}
293
294const readFileReplace = cache((file: string) => {
295 let contents = readFile(file)

Callers

nothing calls this directly

Calls 1

sliceMethod · 0.80

Tested by

no test coverage detected