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.
- package/ChildCards.astro +10 -3
- 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
|
-
|
|
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
|
|
110
|
-
const indexEntry = (pages as any[]).find(p =>
|
|
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());
|