2020-10-16 11:17:50 -07:00
|
|
|
<template>
|
|
|
|
<span>
|
2020-10-25 05:05:52 -07:00
|
|
|
<img v-if="provider.icon.startsWith('https://')" :src="provider.icon" class="icon"/>
|
|
|
|
<Icon v-else :v="provider.icon" :set="provider.iconSet || 'l'"/>
|
2020-10-16 11:17:50 -07:00
|
|
|
<a :href="link" target="_blank" rel="noopener">
|
2020-10-25 05:05:52 -07:00
|
|
|
{{provider.text}}
|
2020-10-16 11:17:50 -07:00
|
|
|
</a>
|
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import {clearUrl} from "../src/helpers";
|
|
|
|
|
2020-10-25 05:05:52 -07:00
|
|
|
const LINK_PROVIDERS = {
|
|
|
|
twitter: {
|
|
|
|
regex: '^https://twitter.com/([^/]+)',
|
|
|
|
icon: 'twitter',
|
|
|
|
iconSet: 'b',
|
|
|
|
},
|
|
|
|
email: {
|
|
|
|
regex: '^mailto:([^/]+)',
|
|
|
|
icon: 'envelope',
|
|
|
|
},
|
|
|
|
reddit: {
|
|
|
|
regex: '^https://reddit.com/u/([^/]+)',
|
|
|
|
icon: 'reddit',
|
|
|
|
iconSet: 'b',
|
|
|
|
},
|
|
|
|
telegram: {
|
|
|
|
regex: '^https://t.me/([^/]+)',
|
|
|
|
icon: 'telegram',
|
|
|
|
iconSet: 'b',
|
|
|
|
},
|
|
|
|
paypal: {
|
|
|
|
regex: '^https://paypal.me/([^/]+)',
|
|
|
|
icon: 'paypal',
|
|
|
|
iconSet: 'b',
|
|
|
|
},
|
|
|
|
cake: {
|
|
|
|
regex: '^https://cake.avris.it/([bgoprc][A-E][0-6])$',
|
|
|
|
icon: 'https://cake.avris.it/favicon.png',
|
|
|
|
},
|
|
|
|
};
|
2020-10-16 11:17:50 -07:00
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
link: { required: true },
|
|
|
|
},
|
|
|
|
computed: {
|
2020-10-25 05:05:52 -07:00
|
|
|
provider() {
|
|
|
|
for (let name in LINK_PROVIDERS) {
|
|
|
|
if (!LINK_PROVIDERS.hasOwnProperty(name)) { continue; }
|
|
|
|
const provider = LINK_PROVIDERS[name];
|
|
|
|
const m = this.link.match(provider.regex);
|
|
|
|
if (m) {
|
|
|
|
return {
|
|
|
|
...provider,
|
|
|
|
text: m[1],
|
|
|
|
};
|
|
|
|
}
|
2020-10-18 02:43:56 -07:00
|
|
|
}
|
|
|
|
|
2020-10-16 11:17:50 -07:00
|
|
|
return {
|
2020-10-25 05:05:52 -07:00
|
|
|
icon: 'globe-europe',
|
|
|
|
text: clearUrl(this.link),
|
2020-10-18 02:43:56 -07:00
|
|
|
}
|
2020-10-16 11:17:50 -07:00
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
2020-10-18 02:43:56 -07:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.icon {
|
|
|
|
height: 1em;
|
|
|
|
}
|
|
|
|
</style>
|