diff --git a/src/components/link-preview/link-preview.js b/src/components/link-preview/link-preview.js new file mode 100644 index 00000000..2f6da55e --- /dev/null +++ b/src/components/link-preview/link-preview.js @@ -0,0 +1,21 @@ +const LinkPreview = { + name: 'LinkPreview', + props: [ + 'card', + 'size', + 'nsfw' + ], + computed: { + useImage () { + // Currently BE shoudn't give cards if tagged NSFW, this is a bit paranoid + // as it makes sure to hide the image if somehow NSFW tagged preview can + // exist. + return this.card.image && !this.nsfw && this.size !== 'hide' + }, + useDescription () { + return this.card.description && /\S/.test(this.card.description) + } + } +} + +export default LinkPreview diff --git a/src/components/link-preview/link-preview.vue b/src/components/link-preview/link-preview.vue new file mode 100644 index 00000000..9b3f2550 --- /dev/null +++ b/src/components/link-preview/link-preview.vue @@ -0,0 +1,79 @@ + + + + + + + diff --git a/src/components/status/status.js b/src/components/status/status.js index 443e6b42..558125df 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -5,6 +5,7 @@ import DeleteButton from '../delete_button/delete_button.vue' import PostStatusForm from '../post_status_form/post_status_form.vue' import UserCardContent from '../user_card_content/user_card_content.vue' import StillImage from '../still-image/still-image.vue' +import LinkPreview from '../link-preview/link-preview.vue' import { filter, find } from 'lodash' import { highlightClass, highlightStyle } from '../../services/user_highlighter/user_highlighter.js' import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator' @@ -220,7 +221,8 @@ const Status = { DeleteButton, PostStatusForm, UserCardContent, - StillImage + StillImage, + LinkPreview }, methods: { visibilityIcon (visibility) { diff --git a/src/components/status/status.vue b/src/components/status/status.vue index 5c956467..d88428c7 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -98,6 +98,10 @@ +