Skip to content

Commit

Permalink
Add #36 {{count}} variable to HTML details tag
Browse files Browse the repository at this point in the history
  • Loading branch information
JackGruber committed Dec 12, 2022
1 parent 04b30e7 commit fff48e5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions src/noteoverview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ export namespace noteoverview {

await addNoteCount(overviewContent, noteCount, options);

await addHTMLDetailsTag(overviewContent, options);
await addHTMLDetailsTag(overviewContent, noteCount, options);
}

overviewContent.unshift(
Expand All @@ -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(`<summary>${options.details.summary}</summary>`);
const summary = options.details.summary.replace(
"{{count}}",
noteCount.toString()
);
overview.unshift(`<summary>${summary}</summary>`);
}
overview.unshift(
`<details ` + (options.details.open === true ? ` open` : `close`) + `>`
Expand Down

0 comments on commit fff48e5

Please sign in to comment.