From 7ea29a02aba2aa20c248d58f80c0c3d89dd67207 Mon Sep 17 00:00:00 2001 From: Anand Chowdhary Date: Tue, 22 Nov 2022 10:44:20 +0100 Subject: [PATCH] :sparkles: Add support for attributes --- src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 33a64c5..136fd85 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,6 +15,7 @@ interface Note { excerpt?: string; date: Date; words: number; + attributes?: Record; } /** @@ -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, @@ -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, }; };