-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: recursive
getCollection()
hanging (#6257)
* fix: avoid trying to SSR md?astroPropagatedAssets * test: layout prop with recursive getCollection * chore: changeset
- Loading branch information
1 parent
802ae45
commit 2fec478
Showing
6 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Fix: prevent dev server hanging for `getCollection()` calls within a layout when using the `layout` prop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
packages/astro/test/fixtures/content/src/components/LayoutProp.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
import { CollectionEntry, getCollection } from 'astro:content'; | ||
// Test for recursive `getCollection()` calls | ||
const blog = await getCollection('blog'); | ||
type Props = { | ||
content: CollectionEntry<'blog'>['data']; | ||
}; | ||
const { | ||
content: { title }, | ||
} = Astro.props; | ||
--- | ||
|
||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<meta name="generator" content={Astro.generator} /> | ||
<title>With Layout Prop</title> | ||
</head> | ||
<body data-layout-prop="true"> | ||
<h1>{title}</h1> | ||
<nav> | ||
<ul> | ||
{blog.map((post) => ( | ||
<li> | ||
<a href={post.slug}>{post.data.title}</a> | ||
</li> | ||
))} | ||
</ul> | ||
</nav> | ||
<slot /> | ||
</body> | ||
</html> | ||
|
9 changes: 9 additions & 0 deletions
9
packages/astro/test/fixtures/content/src/content/blog/with-layout-prop.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: With Layout Prop | ||
description: Use a layout prop in a content collection | ||
layout: "../../components/LayoutProp.astro" | ||
--- | ||
|
||
## Content with a layout prop | ||
|
||
Sure, why not? |
7 changes: 7 additions & 0 deletions
7
packages/astro/test/fixtures/content/src/pages/with-layout-prop.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
import { getEntryBySlug } from 'astro:content'; | ||
const entry = await getEntryBySlug('blog', 'with-layout-prop'); | ||
const { Content } = await entry.render(); | ||
--- | ||
<Content /> |