json-theme-even-fork/components/link.js

10 lines
289 B
JavaScript
Raw Normal View History

import html from '../utils/html.js'
const formatURL = url => url.replace(/^(https?:|)\/\//, '').replace(/\/$/, '')
export default function Link(url, name) {
return name
? (url ? html`<a href="${url}">${name}</a>` : name)
: url && html`<a href="${url}">${formatURL(url)}</a>`
}