Skip to content

Commit

Permalink
Merge pull request #45 from turulix/fixes-10
Browse files Browse the repository at this point in the history
More Improvements
  • Loading branch information
turulix authored May 3, 2023
2 parents e1a012d + d73b027 commit fcd9556
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ From now on you should be able to use folders like they are a normal note!

Folders will also be added to the Graph View by default and link all files that are contained within it :D

#### Manual Indexing

You can also use the ``folder-index-content`` Block processor directly like this:

````
```folder-index-content
```
````

to include the content of the folder index in any note you want

#### Frontmatter

| Key | Description |
|-------|---------------------------------------------------|
| title | This will overwrite the Filename inside the Index |

### Manual Installation

1. Go to [Releases](https://github.com/turulix/obsidian-folder-index/releases) and download the ZIP file from the latest
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-folder-index",
"name": "Folder Index",
"version": "1.0.18",
"version": "1.0.19",
"minAppVersion": "1.1.16",
"description": "This Plugin will automatically generate a TOC for the current Folder.",
"author": "turulix",
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": "obsidian-sample-plugin",
"version": "1.0.18",
"version": "1.0.19",
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
"main": "main.js",
"scripts": {
Expand Down
14 changes: 13 additions & 1 deletion src/types/MarkdownTextRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class MarkdownTextRenderer {

private buildContentMarkdownText(file: TFile, indentLevel: number, isFolder = false): string {
let markdownText = ""
markdownText += this.buildMarkdownLinkString(file.basename, encodeURI(file.path), indentLevel, isFolder)
markdownText += this.buildMarkdownLinkString(this.getTitleFromPath(file.path), encodeURI(file.path), indentLevel, isFolder)

const headers: HeadingCache[] | null = this.app.metadataCache.getFileCache(file)?.headings
if (headers && !this.plugin.settings.disableHeadlines) {
Expand Down Expand Up @@ -103,6 +103,18 @@ export class MarkdownTextRenderer {
return link
}

private getTitleFromPath(path: string): string {
const file = this.app.vault.getAbstractFileByPath(path)
if (file instanceof TFile) {
const cache = this.app.metadataCache.getFileCache(file)
if (cache) {
return cache.frontmatter?.title ?? file.basename
}
return file.basename
}
return "Something went wrong. Please report this issue."
}

private buildHeaderChain(header: HeaderWrapper): string {
if (header.parent) {
return `${this.buildHeaderChain(header.parent)}#${encodeURI(header.header.heading)}`
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"1.0.15": "1.1.16",
"1.0.16": "1.1.16",
"1.0.17": "1.1.16",
"1.0.18": "1.1.16"
"1.0.18": "1.1.16",
"1.0.19": "1.1.16"
}

0 comments on commit fcd9556

Please sign in to comment.