Skip to content

Commit

Permalink
feat: cleanPath (re)introduced
Browse files Browse the repository at this point in the history
  • Loading branch information
akosbalasko authored Aug 17, 2021
2 parents 2562615 + dfecc93 commit 62a6797
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
32 changes: 30 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ interface ZoottelkeeperPluginSettings {
indexItemStyle: IndexItemStyle;
indexTagValue: string;
indexTagBoolean: boolean;
cleanPathBoolean: boolean;
}

interface GeneralContentOptions {
Expand All @@ -19,6 +20,7 @@ const DEFAULT_SETTINGS: ZoottelkeeperPluginSettings = {
indexItemStyle: IndexItemStyle.PureLink,
indexTagValue: 'MOC',
indexTagBoolean: true,
cleanPathBoolean: true,
};

export default class ZoottelkeeperPlugin extends Plugin {
Expand Down Expand Up @@ -204,7 +206,7 @@ export default class ZoottelkeeperPlugin extends Plugin {
}
};

generateIndexItem = (path: string): string => {
generateFormattedIndexItem = (path: string): string => {
switch (this.settings.indexItemStyle) {
case IndexItemStyle.PureLink:
return `[[${path}]]`;
Expand All @@ -215,6 +217,21 @@ export default class ZoottelkeeperPlugin extends Plugin {
};
}

generateIndexItem = (path: string): string => {
let internalFormattedIndex;
if (this.settings.cleanPathBoolean) {
const cleanPath = ( path.endsWith(".md"))
? path.replace(/\.md$/,'')
: path;
const fileName = cleanPath.split("/").pop();
internalFormattedIndex = `${cleanPath}|${fileName}`;
}
else {
internalFormattedIndex = path;
}
return this.generateFormattedIndexItem(internalFormattedIndex);
}

generateIndexFolderItem = (path: string): string => {
return this.generateIndexItem(this.getInnerIndexFilePath(path));
}
Expand Down Expand Up @@ -295,7 +312,18 @@ class ZoottelkeeperPluginSettingTab extends PluginSettingTab {
containerEl.createEl('h2', { text: 'Zoottelkeeper Settings' });

containerEl.createEl('h3', { text: 'General Settings' });

new Setting(containerEl)
.setName("Clean Files")
.setDesc(
"This enables you to only show the files without path and '.md' ending in preview mode."
)
.addToggle((t) => {
t.setValue(this.plugin.settings.cleanPathBoolean);
t.onChange(async (v) => {
this.plugin.settings.cleanPathBoolean = v;
await this.plugin.saveSettings();
});
});
new Setting(containerEl)
.setName('List Style')
.setDesc('Select the style of the index-list.')
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zoottelkeeper-obsidian-plugin",
"version": "0.8.0",
"version": "0.9.0",
"description": "This plugin automatically creates, maintains and tags MOCs for all your folders.",
"main": "main.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"0.5.2": "0.12.1",
"0.5.3": "0.12.1",
"0.6.0": "0.12.1",
"0.8.0": "0.12.1"
"0.8.0": "0.12.1",
"0.9.0": "0.12.1"
}

0 comments on commit 62a6797

Please sign in to comment.