some suggestions about ”Add File Link“ function #555
dragonlau0924
started this conversation in
General
Replies: 1 comment
-
Hi @dragonlau0924 , you can do that by modifying the You could do it in the following way: format_note_with_url(note, url, field) {
let mdFilename = ""
// We separate the string by "&file=".
const splitUrl = url.split("&file=");
// Check if the split resulted in two parts
if (splitUrl.length === 2) {
// Extract the part after "&file="
const encodedPathWithExtension = splitUrl[1]; // Extracted part containing path with extension
const decodedPathWithExtension = decodeURIComponent(encodedPathWithExtension);
// Split the filename from its directory path
const pathSegments = decodedPathWithExtension.split('/');
const filenameWithExtension = pathSegments.pop()?.trim();
// Check if the filename with extension is not empty
if (filenameWithExtension) {
// Split the filename from its extension
const filenameSegments = filenameWithExtension.split('.');
mdFilename = filenameSegments[0]?.trim();
}
}
note.fields[field] += '<br><a href="' + url + `" class="obsidian-link">Obsidian${mdFilename ? " - " + mdFilename : ""}</a>`;
} What this basically does:
If you want to try the new changes:
I will also suggest the change in a PR, in case the maintainers want to implement it. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello developer, thank you very much for sharing the Anki plugin. I have some suggestions. Could you please display the link passed into Anki in the "Add File Link" as a file name instead of "Obsidian"? This would make it easier for me to know which note I have reviewed, which would be more practical.
Beta Was this translation helpful? Give feedback.
All reactions