Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link Folder Fix #13

Merged
merged 3 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion data.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"linkPrefix": "-",
"showFileEnding": false,
"linkFolder": false,
"embedFile": false,
"shortLinks": false,
"mySetting": "-"
}
}
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-file-link",
"name": "Better File Link",
"version": "1.1.3",
"version": "1.1.4",
"minAppVersion": "0.9.12",
"description": "A plugin to add better external file links to notes.",
"author": "Marc Julian Schwarz",
Expand Down
18 changes: 9 additions & 9 deletions src/FileEmbeder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { FileLinkSettings } from "./interfaces";
export class FileEmbeder {
attachementFolder: string;
basePath: string;

settings: FileLinkSettings;

constructor(
Expand Down Expand Up @@ -68,32 +67,33 @@ export class FileEmbeder {
return { path, pathComponents, filename };
}

linkFor(file: File, prefix: boolean) {
let { path, pathComponents, filename } = this.pathInfo(file);
linkFor(file: File, printPrefix: boolean) {
let { path, pathComponents, filename: linkName } = this.pathInfo(file);
let prefixString = "";

if (!this.settings.showFileEnding) {
let filenameComponents = filename.split(".");
let filenameComponents = linkName.split(".");
filenameComponents.pop();
filename = filenameComponents.join(".");
linkName = filenameComponents.join(".");
}

if (this.settings.linkFolder) {
pathComponents.pop();
linkName = pathComponents[pathComponents.length - 1]; // .peek()
path = pathComponents.join("/");
}
if (prefix) {

if (printPrefix) {
prefixString = this.settings.linkPrefix;
}

if (this.settings.shortLinks) {
return prefixString + "[" + filename + "](<file:///" + path + ">)\n";
return prefixString + "[" + linkName + "](<file:///" + path + ">)\n";
}

return (
prefixString +
"[" +
filename +
linkName +
"](file:///" +
encodeURIComponent(path) +
")\n"
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"1.1.0": "0.9.12",
"1.1.1": "0.9.12",
"1.1.2": "0.9.12",
"1.1.3": "0.9.12"
"1.1.3": "0.9.12",
"1.1.4": "0.9.12"
}