FilePathLink.tsx
components/FilePathLink.tsx
43
Lines
3242
Bytes
1
Exports
4
Imports
10
Keywords
What this is
This page documents one file from the repository and includes its full source so you can read it without leaving the docs site.
Beginner explanation
This file is one piece of the larger system. Its name, directory, imports, and exports show where it fits. Start by reading the exports and related files first.
How it is used
Start from the exports list and related files. Those are the easiest clues for where this file fits into the system.
Expert explanation
Architecturally, this file intersects with file-tools, ui-flow. It contains 43 lines, 4 detected imports, and 1 detected exports.
Important relationships
Detected exports
FilePathLink
Keywords
filepathreactlinkfilechildrenhrefpathtofileurlpathtextelse
Detected imports
react/compiler-runtimereacturl../ink/components/Link.js
Source notes
This page embeds the full file contents. Small or leaf files are still indexed honestly instead of being over-explained.
Full source
import { c as _c } from "react/compiler-runtime";
import React from 'react';
import { pathToFileURL } from 'url';
import Link from '../ink/components/Link.js';
type Props = {
/** The absolute file path */
filePath: string;
/** Optional display text (defaults to filePath) */
children?: React.ReactNode;
};
/**
* Renders a file path as an OSC 8 hyperlink.
* This helps terminals like iTerm correctly identify file paths
* even when they appear inside parentheses or other text.
*/
export function FilePathLink(t0) {
const $ = _c(5);
const {
filePath,
children
} = t0;
let t1;
if ($[0] !== filePath) {
t1 = pathToFileURL(filePath);
$[0] = filePath;
$[1] = t1;
} else {
t1 = $[1];
}
const t2 = children ?? filePath;
let t3;
if ($[2] !== t1.href || $[3] !== t2) {
t3 = <Link url={t1.href}>{t2}</Link>;
$[2] = t1.href;
$[3] = t2;
$[4] = t3;
} else {
t3 = $[4];
}
return t3;
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJSZWFjdCIsInBhdGhUb0ZpbGVVUkwiLCJMaW5rIiwiUHJvcHMiLCJmaWxlUGF0aCIsImNoaWxkcmVuIiwiUmVhY3ROb2RlIiwiRmlsZVBhdGhMaW5rIiwidDAiLCIkIiwiX2MiLCJ0MSIsInQyIiwidDMiLCJocmVmIl0sInNvdXJjZXMiOlsiRmlsZVBhd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