Skip to content

Commit

Permalink
Improve visual hint of external links
Browse files Browse the repository at this point in the history
  • Loading branch information
thelegy committed Mar 1, 2024
1 parent 562ce3e commit 345d75d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function rehypeExternalLinksPlugin() {
properties: (element) => ({
className: twMerge(
element.properties.className?.toString(),
'after:ml-1 after:mask-externalLink after:[mask-position:center] after:[mask-repeat:no-repeat] after:size-[1em] after:align-text-top after:inline-block after:bg-current',
'after:external-link after:ml-1',
),
}),
})
Expand Down
17 changes: 16 additions & 1 deletion tailwind.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import plugin from 'tailwindcss/plugin'

const tailwindPlugin = plugin(({ theme, matchUtilities }) => {
const tailwindPlugin = plugin(({ theme, matchUtilities, addComponents }) => {
matchUtilities(
{
mask: (value) => ({
Expand All @@ -16,6 +16,21 @@ const tailwindPlugin = plugin(({ theme, matchUtilities }) => {
},
},
)
addComponents({
'.external-link': {
'--size': '1em',
mask: theme('backgroundImage.externalLink'),
maskSize: 'contain',
maskRepeat: 'no-repeat',
maskPosition: 'center',
backgroundColor: 'currentcolor',
height: 'var(--size)',
width: 'var(--size)',
display: 'inline-block',
verticalAlign: 'baseline',
marginBottom: 'calc(-.15 * var(--size))',
},
})
})

export default {
Expand Down

0 comments on commit 345d75d

Please sign in to comment.