mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
feat(hyperlinking): hyperlinking URLs in the channel descriptions
This commit is contained in:
parent
d3f4653e8a
commit
1a7337a170
2 changed files with 11 additions and 1 deletions
|
@ -4,7 +4,7 @@
|
|||
<div v-if="channel" v-show="!channel.error">
|
||||
<h1 class="uk-text-center"><img height="48" width="48" v-bind:src="channel.avatarUrl" />{{ channel.name }}</h1>
|
||||
<img v-if="channel.bannerUrl" v-bind:src="channel.bannerUrl" style="width: 100%" loading="lazy" />
|
||||
<p style="white-space: pre-wrap">{{ channel.description }}</p>
|
||||
<p style="white-space: pre-wrap"><span v-html="urlify(channel.description)"></span></p>
|
||||
|
||||
<button
|
||||
v-if="authenticated"
|
||||
|
|
10
src/main.js
10
src/main.js
|
@ -158,6 +158,16 @@ const mixin = {
|
|||
timeAgo(time) {
|
||||
return timeAgo.format(time);
|
||||
},
|
||||
urlify(string) {
|
||||
const regex = /(((https?:\/\/)|(www\.))[^\s]+)/g;
|
||||
if (!string) return '';
|
||||
return string.replace(regex, (url) => {
|
||||
if (!url.match('^https?:\\/\\/')) { // If URL does not have http(s), we're adding it manually.
|
||||
return `<a class="uk-button uk-button-text" href="http://${url}" target="_blank">${url}</a>`
|
||||
}
|
||||
return `<a class="uk-button uk-button-text" href="${url}" target="_blank">${url}</a>`
|
||||
})
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
backgroundColor() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue