mirror of
https://github.com/poanse/obsidian-taskmap.git
synced 2026-07-22 06:05:58 +00:00
link hotfix
This commit is contained in:
parent
f1ad3fe0cd
commit
1f49b8583f
2 changed files with 15 additions and 4 deletions
|
|
@ -28,8 +28,19 @@ export function nameFromLink(app: App, s: string) {
|
|||
return file.basename;
|
||||
}
|
||||
|
||||
export function generateMarkdownLinkFromTask(task: TaskData) {
|
||||
return `[${task.name}](${task.path})`;
|
||||
export function generateTextContentFromTask(app: App, task: TaskData) {
|
||||
if (task.path) {
|
||||
const file = app.vault.getFileByPath(task.path);
|
||||
if (file) {
|
||||
return app.fileManager.generateMarkdownLink(
|
||||
file,
|
||||
"",
|
||||
undefined,
|
||||
taskNameFromFile(file),
|
||||
);
|
||||
}
|
||||
}
|
||||
return task.name;
|
||||
}
|
||||
|
||||
/** True if `path` is a file inside `folderPath` (not a false `startsWith` on the folder segment). */
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
import {LinkSuggest} from "../helpers/LinkSuggest";
|
||||
import type {Context} from "../Context.svelte.js";
|
||||
import {
|
||||
generateMarkdownLinkFromTask,
|
||||
generateTextContentFromTask,
|
||||
isLink,
|
||||
linkFromFilePath,
|
||||
nameFromLink, taskNameFromFile,
|
||||
|
|
@ -102,7 +102,7 @@
|
|||
return;
|
||||
}
|
||||
textPreviewEl.empty(); // Clear previous render
|
||||
const content = taskData.path ? generateMarkdownLinkFromTask(taskData) : taskData.name;
|
||||
const content = generateTextContentFromTask(context.app, taskData);
|
||||
await MarkdownRenderer.render(
|
||||
context.app,
|
||||
content,
|
||||
|
|
|
|||
Loading…
Reference in a new issue