Skip to content

Commit

Permalink
✨ Add support for attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Nov 22, 2022
1 parent fedc386 commit 7ea29a0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface Note {
excerpt?: string;
date: Date;
words: number;
attributes?: Record<string, unknown>;
}

/**
Expand Down Expand Up @@ -60,7 +61,7 @@ const parseNoteFile = async (dirName: string, year: string, file: string): Promi
? attributes.description
: "summary" in attributes && typeof attributes.summary === "string"
? attributes.summary
: body.split(title)[1]?.trim();
: body.substring(body.indexOf(title) + 1)?.trim();

return {
slug: file,
Expand All @@ -70,6 +71,7 @@ const parseNoteFile = async (dirName: string, year: string, file: string): Promi
date,
excerpt: excerpt ? truncate(markdownToTxt(excerpt), 500) : undefined,
words: body.split(" ").length,
attributes,
};
};

Expand Down

0 comments on commit 7ea29a0

Please sign in to comment.