astro-better-cards 0.2.3 → 0.2.5

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.
Files changed (2) hide show
  1. package/ChildCards.astro +10 -3
  2. package/package.json +1 -1
package/ChildCards.astro CHANGED
@@ -34,7 +34,11 @@ if (folder !== undefined) {
34
34
  }
35
35
  } else {
36
36
  const pathname = Astro.url.pathname.replace(/^\/+|\/+$/g, '').replace(/\.html$/, '');
37
- prefix = pathname.startsWith(`${collection}/`) ? pathname.slice(collection.length + 1) : pathname;
37
+ if (pathname === '' || pathname === collection) {
38
+ prefix = '';
39
+ } else {
40
+ prefix = pathname.startsWith(`${collection}/`) ? pathname.slice(collection.length + 1) : pathname;
41
+ }
38
42
  }
39
43
  prefix = prefix.replace(/^\/+|\/+$/g, '');
40
44
 
@@ -106,8 +110,11 @@ if (depth === 1) {
106
110
  const subfolderNames = [...new Set(grandchildren.map(p => getSubfolder(p.id)))];
107
111
 
108
112
  groups = await Promise.all(subfolderNames.map(async sf => {
109
- const indexPath = prefix ? `${prefix}/${sf}/index` : `${sf}/index`;
110
- const indexEntry = (pages as any[]).find(p => stripExt(p.id) === indexPath);
113
+ const indexId = prefix ? `${prefix}/${sf}` : sf;
114
+ const indexEntry = (pages as any[]).find(p => {
115
+ const cid = stripExt(p.id);
116
+ return cid === indexId || cid === `${indexId}/index`;
117
+ });
111
118
  const sectionTitle: string = indexEntry
112
119
  ? await md(indexEntry.data.title)
113
120
  : sf.replace(/-/g, ' ').replace(/\b\w/g, (c: string) => c.toUpperCase());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-better-cards",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./Card.astro": "./Card.astro",