MetadataCache.fileToLinktext method
MetadataCache › fileToLinktext
Official
Generates a linktext for a file.If file name is unique, use the filename. If not unique, use full path.
Signature:
fileToLinktext(file: TFile, sourcePath: string, omitMdExtension?: boolean | undefined): stringParameters:
| Parameter | Type | Description |
|---|---|---|
| file | TFile | The file. |
| sourcePath | string | The path of the file where the link will be inserted, used to generate relative paths. |
| omitMdExtension? | boolean | undefined | Whether to omit the .md extension. |
Returns: string
Example:
console.log(metadataCache.fileToLinktext(file, 'baz/qux.md')); // 'bar' or 'foo/bar' depending on whether the file name is unique