astro-better-cards 0.2.5 → 0.2.6

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 +9 -7
  2. package/package.json +1 -1
package/ChildCards.astro CHANGED
@@ -20,9 +20,9 @@ if (folder !== undefined) {
20
20
  const noSlash = folder.replace(/^\/+/, '');
21
21
  prefix = noSlash.startsWith(`${collection}/`) ? noSlash.slice(collection.length + 1) : noSlash;
22
22
  } else if (folder.startsWith('./') || folder.startsWith('../')) {
23
- const pathname = Astro.url.pathname.replace(/^\/+|\/+$/g, '').replace(/\.html$/, '');
23
+ const pathname = Astro.url.pathname.replace(/^\/+|\/+\(/g, '').replace(/\.html\)/, '');
24
24
  const pagePrefix = pathname.startsWith(`${collection}/`) ? pathname.slice(collection.length + 1) : pathname;
25
- const pageFolder = pagePrefix.includes('/') ? pagePrefix.replace(/\/[^/]+$/, '') : '';
25
+ const pageFolder = pagePrefix.includes('/') ? pagePrefix.replace(/\/[^/]+\$/, '') : '';
26
26
  const parts = pageFolder ? pageFolder.split('/') : [];
27
27
  for (const seg of folder.split('/')) {
28
28
  if (seg === '..') parts.pop();
@@ -33,17 +33,17 @@ if (folder !== undefined) {
33
33
  prefix = folder;
34
34
  }
35
35
  } else {
36
- const pathname = Astro.url.pathname.replace(/^\/+|\/+$/g, '').replace(/\.html$/, '');
36
+ const pathname = Astro.url.pathname.replace(/^\/+|\/+\(/g, '').replace(/\.html\)/, '');
37
37
  if (pathname === '' || pathname === collection) {
38
38
  prefix = '';
39
39
  } else {
40
40
  prefix = pathname.startsWith(`${collection}/`) ? pathname.slice(collection.length + 1) : pathname;
41
41
  }
42
42
  }
43
- prefix = prefix.replace(/^\/+|\/+$/g, '');
43
+ prefix = prefix.replace(/^\/+|\/+\$/g, '');
44
44
 
45
45
  function stripExt(id: string): string {
46
- return id.replace(/\.(md|mdx)$/i, '');
46
+ return id.replace(/\.(md|mdx)\$/i, '');
47
47
  }
48
48
 
49
49
  function isDirectChild(id: string): boolean {
@@ -96,7 +96,8 @@ if (depth === 1) {
96
96
  const children = valid.filter(p => isDirectChild(p.id));
97
97
  children.sort((a, b) => (a.data.order ?? 1000) - (b.data.order ?? 1000) || a.data.title.localeCompare(b.data.title));
98
98
  items = await Promise.all(children.map(async p => ({
99
- href: `/${collection}/${stripExt(p.id).replace(/\/index$/, '')}`,
99
+ // FIX: Replaced `/${collection}/` with a single `/`
100
+ href: `/${stripExt(p.id).replace(/\/index$/, '')}`,
100
101
  title: await md(p.data.title),
101
102
  description: p.data.description,
102
103
  icon: p.data.icon ?? null,
@@ -127,7 +128,8 @@ if (depth === 1) {
127
128
  title: sectionTitle,
128
129
  order: sectionOrder,
129
130
  items: await Promise.all(sfItems.map(async p => ({
130
- href: `/${collection}/${stripExt(p.id)}`,
131
+ // FIX: Replaced `/${collection}/` with a single `/`
132
+ href: `/${stripExt(p.id)}`,
131
133
  title: await md(p.data.title),
132
134
  description: p.data.description,
133
135
  icon: p.data.icon ?? null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-better-cards",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./Card.astro": "./Card.astro",