From fff48e538e4b9bc917ba0738eb3b4738b1126f06 Mon Sep 17 00:00:00 2001 From: JackGruber <24863925+JackGruber@users.noreply.github.com> Date: Mon, 12 Dec 2022 19:28:59 +0100 Subject: [PATCH] Add #36 {{count}} variable to HTML details tag --- CHANGELOG.md | 1 + README.md | 3 ++- src/noteoverview.ts | 9 +++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ea0842..49f7819 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Add: #35 Warning color when a taks is close to a due date - Add: Virtual field `link` to display the `source_url` to make the output configurable - Fix: Ignore noteoverview blocks if they start with a codeblock (```) statement +- Add: #36 Variable `{{count}}` to the summary of the details HTML tag ## v1.5.5 (2022-01-26) diff --git a/README.md b/README.md index 9777cd2..8d9b90c 100644 --- a/README.md +++ b/README.md @@ -181,11 +181,12 @@ excerpt: ### details Add the overview into a details section that can open and close on demand. +In the summary the variable `{{count}}` can be used, to display the number of matched notes. ```yml details: open: [true | false] - summary: All notes without a Tag + summary: {{count}} notes without a Tag ``` ### count diff --git a/src/noteoverview.ts b/src/noteoverview.ts index dff5885..6707ab5 100644 --- a/src/noteoverview.ts +++ b/src/noteoverview.ts @@ -867,7 +867,7 @@ export namespace noteoverview { await addNoteCount(overviewContent, noteCount, options); - await addHTMLDetailsTag(overviewContent, options); + await addHTMLDetailsTag(overviewContent, noteCount, options); } overviewContent.unshift( @@ -880,12 +880,17 @@ export namespace noteoverview { export async function addHTMLDetailsTag( overview: string[], + noteCount: number, options: OverviewOptions ) { if (options.details) { overview.unshift(""); if (options.details.summary) { - overview.unshift(`${options.details.summary}`); + const summary = options.details.summary.replace( + "{{count}}", + noteCount.toString() + ); + overview.unshift(`${summary}`); } overview.unshift( `
`