Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions src/components/LinkOut.astro
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
---
const { href, withIcon = true } = Astro.props
let slotContent = await Astro.slots.render('default')
// Remove wrapping <p> tags that MDX adds
slotContent = slotContent.replace(/^<p>(.*)<\/p>$/s, '$1').trim()
---

{
withIcon ? (
<a href={href} target="_blank" rel="noopener noreferrer">
<slot />
<span class="icon" />
</a>
) : (
<a href={href} target="_blank" rel="noopener noreferrer">
<slot />
</a>
)
}
<a href={href} target="_blank" rel="noopener noreferrer"
><Fragment set:html={slotContent} />{withIcon && <span class="icon" />}</a
>

<style>
.icon {
Expand Down