#263 expand links in cards

This commit is contained in:
Avris 2021-09-07 17:37:24 +02:00
parent 3bf10b002b
commit d28553eddc
5 changed files with 9 additions and 6 deletions

View File

@ -77,7 +77,7 @@
<ul class="list-unstyled">
<li v-for="link in profile.links">
<ProfileLink :link="link"/>
<ProfileLink :link="link" :expand="expandLinks"/>
</li>
</ul>
</div>
@ -113,6 +113,7 @@
user: { required: true },
profile: { required: true },
terms: { 'default': null },
expandLinks: { type: Boolean },
},
data() {
return {

View File

@ -14,13 +14,14 @@
mixins: [link],
props: {
link: { required: true },
expand: { type: Boolean },
},
computed: {
linkTrimmed() {
return this.link.trim();
},
niceLink() {
return this.beautifyLink(this.linkTrimmed);
return this.beautifyLink(this.linkTrimmed, this.expand);
},
}
};

View File

@ -83,7 +83,7 @@ export default {
cake: LINK_PROVIDERS.cake,
};
},
beautifyLink(link) {
beautifyLink(link, expand = false) {
for (let name in LINK_PROVIDERS) {
if (!LINK_PROVIDERS.hasOwnProperty(name)) { continue; }
const provider = LINK_PROVIDERS[name];
@ -91,7 +91,7 @@ export default {
if (m) {
return {
...provider,
text: m[1],
text: expand ? clearUrl(link) : m[1],
};
}
}

View File

@ -1,5 +1,5 @@
<template>
<Profile v-if="profile" :user="user" :profile="profile" class="pb-3">
<Profile v-if="profile" :user="user" :profile="profile" class="pb-3" expandLinks>
<nuxt-link to="/">
<h1 class="text-nowrap h5">
<Icon v="tags"/>

View File

@ -49,7 +49,8 @@ export const clearUrl = url => {
.replace('http://www.', '')
.replace('https://www.', '')
.replace('http://', '')
.replace('https://', '');
.replace('https://', '')
.replace('mailto:', '');
const qPos = url.indexOf('?')
if (qPos > -1) {