Skip to content

Commit

Permalink
Fixed a bug. Probably intoduced 3 new ones.
Browse files Browse the repository at this point in the history
  • Loading branch information
turulix committed Mar 21, 2023
1 parent 9d28d08 commit 495ab72
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
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": "v1.0.8",
"version": "v1.0.9",
"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.8",
"version": "1.0.9",
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
"main": "main.js",
"scripts": {
Expand Down
10 changes: 7 additions & 3 deletions src/modules/IndexContentRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class IndexContentRenderer extends MarkdownRenderChild {
}

let headings = this.app.metadataCache.getFileCache(value).headings
headings = headings.sort((a, b) => a.position.start.offset - b.position.start.offset)

const fileLink = this.app.metadataCache.fileToLinktext(value, this.filePath)

Expand All @@ -56,9 +57,12 @@ export class IndexContentRenderer extends MarkdownRenderChild {
}
for (let i = 0; i < headings.length; i++) {
const heading = new FileHeader(headings[i])
const numIndents = new Array(Math.max(1, heading.level - headings[0].level + (this.plugin.settings.skipFirstHeadline ? 1 : 0)));

const indent = numIndents.fill("\t").join("");
//const numIndents = new Array(Math.max(1, heading.level - headings[0].level + (this.plugin.settings.skipFirstHeadline ? 1 : 0)));
let indent = ""
for(let j=0; j<heading.level; j++) {
indent += "\t"
}
//const indent = numIndents.fill("\t").join("");
list.push(`${indent}1. [[${fileLink}#${heading.rawHeading}|${heading.rawHeading}]]`);
}
}
Expand Down

0 comments on commit 495ab72

Please sign in to comment.