mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
refactor: extracting social media to vue component
This commit is contained in:
parent
3ce6313588
commit
75763a6486
42
webapp/components/SocialMedia/SocialMedia.vue
Normal file
42
webapp/components/SocialMedia/SocialMedia.vue
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<template>
|
||||||
|
<ds-space v-if="user.socialMedia && user.socialMedia.length" margin="large">
|
||||||
|
<base-card style="position: relative; height: auto;">
|
||||||
|
<ds-space margin="x-small">
|
||||||
|
<ds-text tag="h5" color="soft">
|
||||||
|
{{ $t('profile.socialMedia') }} {{ userName | truncate(15) }}?
|
||||||
|
</ds-text>
|
||||||
|
<template>
|
||||||
|
<ds-space v-for="link in socialMediaLinks()" :key="link.username" margin="x-small">
|
||||||
|
<a :href="link.url" target="_blank">
|
||||||
|
<img :src="link.favicon" alt="Link:" height="22" width="22" />
|
||||||
|
{{ link.username }}
|
||||||
|
</a>
|
||||||
|
</ds-space>
|
||||||
|
</template>
|
||||||
|
</ds-space>
|
||||||
|
</base-card>
|
||||||
|
</ds-space>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'social-media',
|
||||||
|
props: {
|
||||||
|
userName: {},
|
||||||
|
user: {},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
socialMediaLinks() {
|
||||||
|
const { socialMedia = [] } = this.user
|
||||||
|
return socialMedia.map((socialMedia) => {
|
||||||
|
const { url } = socialMedia
|
||||||
|
const matches = url.match(/^(?:https?:\/\/)?(?:[^@\n])?(?:www\.)?([^:/\n?]+)/g)
|
||||||
|
const [domain] = matches || []
|
||||||
|
const favicon = domain ? `${domain}/favicon.ico` : null
|
||||||
|
const username = url.split('/').pop()
|
||||||
|
return { url, username, favicon }
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@ -87,7 +87,7 @@
|
|||||||
</template>
|
</template>
|
||||||
</base-card>
|
</base-card>
|
||||||
<ds-space />
|
<ds-space />
|
||||||
<ds-heading tag="h3" soft style="text-align: center; margin-bottom: 10px">
|
<ds-heading tag="h3" soft style="text-align: center; margin-bottom: 10px;">
|
||||||
{{ $t('profile.network.title') }}
|
{{ $t('profile.network.title') }}
|
||||||
</ds-heading>
|
</ds-heading>
|
||||||
<follow-list
|
<follow-list
|
||||||
@ -104,7 +104,7 @@
|
|||||||
@fetchAllConnections="fetchAllConnections"
|
@fetchAllConnections="fetchAllConnections"
|
||||||
/>
|
/>
|
||||||
<ds-space v-if="user.socialMedia && user.socialMedia.length" margin="large">
|
<ds-space v-if="user.socialMedia && user.socialMedia.length" margin="large">
|
||||||
<base-card style="position: relative; height: auto">
|
<base-card style="position: relative; height: auto;">
|
||||||
<ds-space margin="x-small">
|
<ds-space margin="x-small">
|
||||||
<ds-text tag="h5" color="soft">
|
<ds-text tag="h5" color="soft">
|
||||||
{{ $t('profile.socialMedia') }} {{ userName | truncate(15) }}?
|
{{ $t('profile.socialMedia') }} {{ userName | truncate(15) }}?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user