Skip to content

Commit

Permalink
Fix external link with context
Browse files Browse the repository at this point in the history
  • Loading branch information
marcodpt committed Sep 23, 2024
1 parent 5ebfdd1 commit 94736d6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ctrl/link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default ({
}
const setTarget = href =>
typeof href == 'string' && href.indexOf('://') > 0 ? '_blank' : null
const ext = target => !target || !extra.title ? '' : node(({
const ext = (target, ctx) => !target || !extra.title || ctx ? '' : node(({
sup, i, text
}) =>
sup({}, [
Expand Down Expand Up @@ -118,7 +118,7 @@ export default ({
}), {})
}, [
ctrl(extra),
ext(target),
ext(target, context),
!download || !mime ? null : a({
class: 'd-none',
href: `data:${mime},`,
Expand Down
33 changes: 33 additions & 0 deletions src/ctrl/link/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,39 @@ export default ({
])
])
)
}, {
title: 'A external link with target _blank and context',
data: [
{
icon: '@github',
title: 'Repository',
context: 'info',
href: 'https://github.com/marcodpt/paw'
}
],
html: html(({
a,
span,
i,
sup,
text
}) =>
a({
class: 'btn btn-info',
href: 'https://github.com/marcodpt/paw',
target: '_blank'
}, [
span({}, [
i({
class: [
'fa-brands',
'fa-github'
]
}),
text(' Repository')
])
])
)
}, {
title: 'A external link with target _blank and no title',
data: [
Expand Down

0 comments on commit 94736d6

Please sign in to comment.