astro-better-cards 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Card.astro CHANGED
@@ -10,16 +10,25 @@ const {
10
10
  comingSoon = false,
11
11
  label,
12
12
  labelFirst = false,
13
+ version,
14
+ badges,
13
15
  } = Astro.props;
14
16
  ---
15
17
  {variant === 'full' && (
16
18
  <a href={href} class="border border-slate-300 dark:bg-slate-900 bg-white border-solid block dark:hover:bg-slate-700 dark:border-slate-600 group hover:bg-slate-300 hover:border-indigo-500 dark:hover:border-indigo-600 rounded-lg overflow-hidden">
17
19
  {cardImage && <img src={cardImage} class="w-full object-cover" alt="" aria-hidden="true" />}
18
20
  <div class="flex items-start gap-x-6 p-5">
19
- {icon && <img class:list={["block w-14 shrink-0", darkIcon ? "dark:hidden" : ""]} src={icon} alt="" aria-hidden="true" />}
20
- {darkIcon && <img class="hidden dark:block w-14 shrink-0" src={darkIcon} alt="" aria-hidden="true" />}
21
+ {icon && <img class:list={["block w-14 h-14 object-contain shrink-0", darkIcon ? "dark:hidden" : ""]} src={icon} alt="" aria-hidden="true" />}
22
+ {darkIcon && <img class="hidden dark:block w-14 h-14 object-contain shrink-0" src={darkIcon} alt="" aria-hidden="true" />}
21
23
  <div>
22
24
  <p class="font-bold group-hover:text-indigo-500 pb-1 text-xl sm:leading-tight sm:pb-2 sm:text-lg md:text-xl lg:text-2xl 2xl:leading-tight" set:html={title}></p>
25
+ {(version || (badges && badges.length > 0)) && (
26
+ <p class="flex items-center gap-1.5 text-xs text-slate-400 dark:text-slate-500 mb-1.5">
27
+ {version && <span>v{version}</span>}
28
+ {version && badges && badges.length > 0 && <span>&mdash;</span>}
29
+ {badges && badges.map((b: string) => <span class={`badge badge-${b}`}>{b}</span>)}
30
+ </p>
31
+ )}
23
32
  {description && <p class="font-normal lg:leading-4 sm:leading-4 text-sm">{description}</p>}
24
33
  </div>
25
34
  </div>
@@ -37,7 +46,7 @@ const {
37
46
  {variant === 'quickstart' && (
38
47
  <a href={href} class={"border border-solid block rounded-lg " + (comingSoon ? "border-slate-800 dark:border-slate-700" : "border-slate-200 dark:bg-slate-900 dark:border-slate-800 bg-white dark:hover:bg-slate-800 dark:hover:border-indigo-500 group hover:bg-slate-100 hover:border-indigo-500")}>
39
48
  <div class="flex items-center gap-x-6 px-5 py-3">
40
- {icon && <img class={"h-9 shrink-0" + (comingSoon ? " opacity-40" : "")} src={icon} alt="" aria-hidden="true" />}
49
+ {icon && <img class={"h-9 w-9 object-contain shrink-0" + (comingSoon ? " opacity-40" : "")} src={icon} alt="" aria-hidden="true" />}
41
50
  <p class={"font-medium group-hover:text-indigo-500 sm:leading-tight text-sm 1xl:leading-tight " + (comingSoon ? "text-slate-400" : "")} set:html={comingSoon ? title + ' * Coming Soon' : title}></p>
42
51
  </div>
43
52
  </a>
package/ChildCards.astro CHANGED
@@ -52,6 +52,10 @@ function isDirectChild(id: string): boolean {
52
52
 
53
53
  function isGrandchildPage(id: string): boolean {
54
54
  const cid = stripExt(id);
55
+ if (!prefix) {
56
+ const parts = cid.split('/');
57
+ return parts.length === 2 && parts[1] !== 'index';
58
+ }
55
59
  if (!cid.startsWith(`${prefix}/`)) return false;
56
60
  const rem = cid.slice(prefix.length + 1);
57
61
  const parts = rem.split('/');
@@ -59,6 +63,7 @@ function isGrandchildPage(id: string): boolean {
59
63
  }
60
64
 
61
65
  function getSubfolder(id: string): string {
66
+ if (!prefix) return stripExt(id).split('/')[0];
62
67
  return stripExt(id).slice(prefix.length + 1).split('/')[0];
63
68
  }
64
69
 
@@ -74,6 +79,8 @@ type NavItem = {
74
79
  icon?: string | null;
75
80
  darkIcon?: string;
76
81
  cardImage?: string;
82
+ version?: string;
83
+ badges?: string[];
77
84
  };
78
85
 
79
86
  type NavGroup = { title: string; order: number; items: NavItem[] };
@@ -91,13 +98,16 @@ if (depth === 1) {
91
98
  icon: p.data.icon ?? null,
92
99
  darkIcon: p.data.darkIcon,
93
100
  cardImage: p.data.cardImage,
101
+ version: p.data.version,
102
+ badges: p.data.badges,
94
103
  })));
95
104
  } else {
96
105
  const grandchildren = valid.filter(p => isGrandchildPage(p.id));
97
106
  const subfolderNames = [...new Set(grandchildren.map(p => getSubfolder(p.id)))];
98
107
 
99
108
  groups = await Promise.all(subfolderNames.map(async sf => {
100
- const indexEntry = (pages as any[]).find(p => stripExt(p.id) === `${prefix}/${sf}/index`);
109
+ const indexPath = prefix ? `${prefix}/${sf}/index` : `${sf}/index`;
110
+ const indexEntry = (pages as any[]).find(p => stripExt(p.id) === indexPath);
101
111
  const sectionTitle: string = indexEntry
102
112
  ? await md(indexEntry.data.title)
103
113
  : sf.replace(/-/g, ' ').replace(/\b\w/g, (c: string) => c.toUpperCase());
@@ -116,6 +126,8 @@ if (depth === 1) {
116
126
  icon: p.data.icon ?? null,
117
127
  darkIcon: p.data.darkIcon,
118
128
  cardImage: p.data.cardImage,
129
+ version: p.data.version,
130
+ badges: p.data.badges,
119
131
  }))),
120
132
  };
121
133
  }));
@@ -128,7 +140,8 @@ if (depth === 1) {
128
140
  <div class="gap-6 mt-6 mb-6 grid grid-cols-1 not-prose lg:grid-cols-2" xmlns="http://www.w3.org/1999/xhtml">
129
141
  {items.map(item => (
130
142
  <Card href={item.href} title={item.title} description={item.description}
131
- icon={item.icon} darkIcon={item.darkIcon} cardImage={item.cardImage} variant="full" />
143
+ icon={item.icon} darkIcon={item.darkIcon} cardImage={item.cardImage}
144
+ version={item.version} badges={item.badges} variant="full" />
132
145
  ))}
133
146
  </div>
134
147
  ) : (
@@ -139,7 +152,8 @@ if (depth === 1) {
139
152
  <div class="gap-6 grid grid-cols-1 not-prose lg:grid-cols-2" xmlns="http://www.w3.org/1999/xhtml">
140
153
  {group.items.map(item => (
141
154
  <Card href={item.href} title={item.title} description={item.description}
142
- icon={item.icon} darkIcon={item.darkIcon} cardImage={item.cardImage} variant="full" />
155
+ icon={item.icon} darkIcon={item.darkIcon} cardImage={item.cardImage}
156
+ version={item.version} badges={item.badges} variant="full" />
143
157
  ))}
144
158
  </div>
145
159
  </Fragment>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-better-cards",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./Card.astro": "./Card.astro",