Skip to content

Commit 5131f7a

Browse files
committed
feat: add "no tags found" results to tag-cloud v1 & v2
1 parent a245f58 commit 5131f7a

File tree

3 files changed

+61
-3
lines changed

3 files changed

+61
-3
lines changed

Snippets/Tag Cloud 1/README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,28 @@ const CreateTagCloud = async ( ) =>
249249
Calculate font size and font color.
250250
*/
251251
252+
let count = 0;
252253
tags.forEach( ( tagInfo, tagName ) =>
253254
{
255+
count++;
254256
const fontSize = Generate_FontSize( tagInfo.backlinks, tagInfo.wordCount );
255257
const color = Generate_Color( tagName, tagInfo );
256258
const length = dv.pages( tagName ).length;
257259
258260
data.push( { name: `\\${tagName}`, id: tagName, length: length, fontSize, color } );
259261
});
260262
263+
/*
264+
No tags found
265+
*/
266+
267+
if (count === 0)
268+
{
269+
const rootNode = dv.el("div", "🔖 No Tags Found", { cls: "atx-tcv1-results_none" });
270+
rootNode.setAttribute("style", "text-align:center;");
271+
return ``;
272+
}
273+
261274
/*
262275
Sorting functions
263276
*/
@@ -435,6 +448,22 @@ Copy the code below and paste it into the new `tag_cloud_v1.css` file which shou
435448
transform: translateX(-50%);
436449
line-height: 19px;
437450
}
451+
452+
/*
453+
Tag Cloud > No results
454+
*/
455+
456+
.atx-tcv1-results_none
457+
{
458+
text-align: center;
459+
font-size: 14pt;
460+
}
461+
462+
.atx-tcv1-results_none_subheader
463+
{
464+
padding-left: 12px;
465+
font-size: 10pt;
466+
}
438467
```
439468
440469
<br />
@@ -606,4 +635,4 @@ let B = Math.floor( ( Math.random( ) * 100 ) + 100 );
606635
607636
For brighter colors, increase `100`. Don't exceed `255`.
608637
609-
For darker colors, decrease `100`. Don't go below `0`.
638+
For darker colors, decrease `100`. Don't go below `0`.

Snippets/Tag Cloud 2/README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,28 @@ const CreateTagCloud = async ( ) =>
316316
Calculate font size and font color.
317317
*/
318318
319+
let count = 0;
319320
tags.forEach( ( tagInfo, tagName ) =>
320321
{
322+
count++;
321323
const fontSize = Generate_FontSize( tagInfo.backlinks, tagInfo.wordCount );
322324
const color = Generate_Color( tagName, tagInfo );
323325
const length = dv.pages( tagName ).length;
324326
325327
data.push( { name: `\\${tagName}`, id: tagName, length: length, fontSize, color } );
326328
});
327329
330+
/*
331+
No tags found
332+
*/
333+
334+
if (count === 0)
335+
{
336+
const rootNode = dv.el("div", "🔖 No Tags Found", { cls: "atx-tcv2-results_none" });
337+
rootNode.setAttribute("style", "text-align:center;");
338+
return ``;
339+
}
340+
328341
/*
329342
Sorting functions
330343
*/
@@ -907,6 +920,22 @@ settings:
907920
transform: translateX( -50% );
908921
line-height: var( --atx-tcv2-counter-bg-size );
909922
}
923+
924+
/*
925+
Tag Cloud > No results
926+
*/
927+
928+
.atx-tcv2-results_none
929+
{
930+
text-align: center;
931+
font-size: 14pt;
932+
}
933+
934+
.atx-tcv2-results_none_subheader
935+
{
936+
padding-left: 12px;
937+
font-size: 10pt;
938+
}
910939
```
911940
912941
<br />
@@ -1129,4 +1158,4 @@ This snippet supports tweaking the look and feel of the cloud & tags using the *
11291158
11301159
</div>
11311160
1132-
<br /><br />
1161+
<br /><br />

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@aetherinox/obsidian-dataview-snippets",
3-
"version": "1.4.2",
3+
"version": "1.4.3",
44
"description": "A collection of Obsidian.md scripts to be used in combination with the dataview plugin.",
55
"homepage": "https://github.com/Aetherinox/obsidian-dataview-snippets",
66
"author": "Aetherinox <[email protected]>",

0 commit comments

Comments
 (0)