Skip to content

Commit d5b6324

Browse files
committed
fix: fixed polymorphic component implementation
1 parent 6877032 commit d5b6324

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/components/Container.astro

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
---
2-
interface Props {
3-
as: keyof Pick<HTMLElementTagNameMap, 'div' | 'section' | 'article' | 'header' | 'footer' | 'code'>;
4-
class?: string
5-
}
2+
import type { Polymorphic } from 'astro/types';
63
7-
const { as: Tag, class: className } = Astro.props;
4+
type LayoutTag = 'section' | 'div' | 'article' | 'header' | 'footer' | 'code';
5+
6+
type Props<Tag extends LayoutTag> = Polymorphic<{
7+
as: Tag;
8+
class?: string;
9+
}>;
10+
11+
const { as: Tag = 'div', class: className } = Astro.props as Props<LayoutTag>;
812
---
913

1014
<Tag class:list={[

0 commit comments

Comments
 (0)