Skip to content

Commit

Permalink
Fix #1 - indexing whole note
Browse files Browse the repository at this point in the history
  • Loading branch information
LoyalPotato committed Aug 20, 2023
1 parent bbf542e commit 8daaa15
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/indexSvc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@ export function generateIndex(content: string): string {
let index = "\n## Content Index\n\n";
const indexPos: number[] = [];
let contents = "";
let isNewIndex = false;

for (let i = 0; i < lines.length; ++i) {
const line = lines[i];
if (!line) continue;
if (line.includes("## Content Index")) {
console.log("index start", i);
indexPos[0] = i;
} else if (indexPos[0] != null && line.includes("- [")) {
} else if (!isNewIndex && line.includes("- [")) {
indexPos[1] = i;
console.log("index val", i);
} else if (line.startsWith("#")) {
if (indexPos.length === 0) {
console.log("no index start", i);
isNewIndex = true;
indexPos[0] = i + 1;
}
contents += `${generateLink(line)}\n`;
Expand Down

0 comments on commit 8daaa15

Please sign in to comment.