Skip to content

Commit a4ec6da

Browse files
committed
Aside: Add support for icons attribute.
Only built-icons will be supported for now. This commit does not add support for the `:::` markdown shorthand for defining an aside, that will be done in the next commit.
1 parent 4825271 commit a4ec6da

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

docs/src/content/docs/guides/components.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,10 @@ Other content is also supported in asides.
282282
</Aside>
283283

284284
<Aside type="danger">Do not give your password to anyone.</Aside>
285+
286+
<Aside icon="heart">
287+
Aside with a custom icon. The icon must be part of starlight's icon list.
288+
</Aside>
285289
````
286290

287291
The above code generates the following on the page:
@@ -306,6 +310,11 @@ Other content is also supported in asides.
306310

307311
<Aside type="danger">Do not give your password to anyone.</Aside>
308312

313+
<Aside icon="heart">
314+
{' '}
315+
Aside with a custom icon. The icon must be part of starlight's icon list.
316+
</Aside>
317+
309318
Starlight also provides a custom syntax for rendering asides in Markdown and MDX as an alternative to the `<Aside>` component.
310319
See the [“Authoring Content in Markdown”](/guides/authoring-content/#asides) guide for details of the custom syntax.
311320

packages/starlight/user-components/Aside.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface Props {
1212
title?: string;
1313
}
1414
15-
let { type = 'note', title } = Astro.props;
15+
let { type = 'note', title, icon } = Astro.props;
1616
1717
if (!asideVariants.includes(type)) {
1818
throw new AstroError(
@@ -30,7 +30,7 @@ if (!title) {
3030

3131
<aside aria-label={title} class={`starlight-aside starlight-aside--${type}`}>
3232
<p class="starlight-aside__title" aria-hidden="true">
33-
<Icon name={icons[type]} class="starlight-aside__icon" />{title}
33+
<Icon name={icon || icons[type]} class="starlight-aside__icon" />{title}
3434
</p>
3535
<section class="starlight-aside__content">
3636
<slot />

0 commit comments

Comments
 (0)