Skip to content

Commit 091b4b5

Browse files
Merge pull request #62 from interledger/jm/linkout-multiline-fix
fix the extra <p> in the linkout component
2 parents 049c65c + 956f95a commit 091b4b5

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/components/LinkOut.astro

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
---
22
const { href, withIcon = true } = Astro.props
3+
let slotContent = await Astro.slots.render('default')
4+
// Remove wrapping <p> tags that MDX adds
5+
slotContent = slotContent.replace(/^<p>(.*)<\/p>$/s, '$1').trim()
36
---
47

5-
{
6-
withIcon ? (
7-
<a href={href} target="_blank" rel="noopener noreferrer">
8-
<slot />
9-
<span class="icon" />
10-
</a>
11-
) : (
12-
<a href={href} target="_blank" rel="noopener noreferrer">
13-
<slot />
14-
</a>
15-
)
16-
}
8+
<a href={href} target="_blank" rel="noopener noreferrer"
9+
><Fragment set:html={slotContent} />{withIcon && <span class="icon" />}</a
10+
>
1711

1812
<style>
1913
.icon {

0 commit comments

Comments
 (0)