2019-07-06 16:56:13 -05:00
|
|
|
<template>
|
2020-07-11 10:17:30 -05:00
|
|
|
<div class="xcukqgmh">
|
2020-01-29 13:37:25 -06:00
|
|
|
<portal to="avatar" v-if="page"><mk-avatar class="avatar" :user="page.user" :disable-preview="true"/></portal>
|
|
|
|
<portal to="title" v-if="page">{{ page.title || page.name }}</portal>
|
|
|
|
|
2020-01-29 20:10:42 -06:00
|
|
|
<div class="_card" v-if="page" :key="page.id">
|
2020-01-29 15:19:18 -06:00
|
|
|
<div class="_title">{{ page.title }}</div>
|
2020-04-13 10:13:49 -05:00
|
|
|
<div class="banner">
|
|
|
|
<img :src="page.eyeCatchingImage.url" v-if="page.eyeCatchingImageId"/>
|
|
|
|
</div>
|
2020-01-29 15:19:18 -06:00
|
|
|
<div class="_content">
|
|
|
|
<x-page :page="page"/>
|
|
|
|
</div>
|
|
|
|
<div class="_footer">
|
|
|
|
<small>@{{ page.user.username }}</small>
|
|
|
|
<template v-if="$store.getters.isSignedIn && $store.state.i.id === page.userId">
|
2020-07-24 11:56:52 -05:00
|
|
|
<router-link :to="`/my/pages/edit/${page.id}`">{{ $t('_pages.editThisPage') }}</router-link>
|
|
|
|
<a v-if="$store.state.i.pinnedPageId === page.id" @click="pin(false)">{{ $t('unpin') }}</a>
|
|
|
|
<a v-else @click="pin(true)">{{ $t('pin') }}</a>
|
2020-01-29 15:19:18 -06:00
|
|
|
</template>
|
2020-07-24 11:56:52 -05:00
|
|
|
<router-link :to="`./${page.name}/view-source`">{{ $t('_pages.viewSource') }}</router-link>
|
2020-01-29 15:19:18 -06:00
|
|
|
<div class="like">
|
2020-02-18 13:15:14 -06:00
|
|
|
<button class="_button" @click="unlike()" v-if="page.isLiked" :title="$t('_pages.unlike')"><fa :icon="faHeartS"/></button>
|
|
|
|
<button class="_button" @click="like()" v-else :title="$t('_pages.like')"><fa :icon="faHeartR"/></button>
|
2020-01-29 15:19:18 -06:00
|
|
|
<span class="count" v-if="page.likedCount > 0">{{ page.likedCount }}</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-01-29 13:37:25 -06:00
|
|
|
</div>
|
2019-07-06 16:56:13 -05:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2020-02-18 13:15:14 -06:00
|
|
|
import { faHeart as faHeartS } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import { faHeart as faHeartR } from '@fortawesome/free-regular-svg-icons';
|
2019-07-06 16:56:13 -05:00
|
|
|
import XPage from '../components/page/page.vue';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
components: {
|
|
|
|
XPage
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
pageName: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
username: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
page: null,
|
2020-02-18 13:15:14 -06:00
|
|
|
faHeartS, faHeartR
|
2019-07-06 16:56:13 -05:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
path(): string {
|
|
|
|
return this.username + '/' + this.pageName;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
path() {
|
|
|
|
this.fetch();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
this.fetch();
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
fetch() {
|
|
|
|
this.$root.api('pages/show', {
|
|
|
|
name: this.pageName,
|
|
|
|
username: this.username,
|
|
|
|
}).then(page => {
|
|
|
|
this.page = page;
|
|
|
|
});
|
|
|
|
},
|
2020-01-29 15:19:18 -06:00
|
|
|
|
|
|
|
like() {
|
|
|
|
this.$root.api('pages/like', {
|
|
|
|
pageId: this.page.id,
|
|
|
|
}).then(() => {
|
|
|
|
this.page.isLiked = true;
|
|
|
|
this.page.likedCount++;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
unlike() {
|
|
|
|
this.$root.api('pages/unlike', {
|
|
|
|
pageId: this.page.id,
|
|
|
|
}).then(() => {
|
|
|
|
this.page.isLiked = false;
|
|
|
|
this.page.likedCount--;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
pin(pin) {
|
|
|
|
this.$root.api('i/update', {
|
|
|
|
pinnedPageId: pin ? this.page.id : null,
|
|
|
|
}).then(() => {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'success',
|
2020-02-18 06:27:47 -06:00
|
|
|
iconOnly: true, autoClose: true
|
2020-01-29 15:19:18 -06:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2019-07-06 16:56:13 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2020-01-29 13:37:25 -06:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.xcukqgmh {
|
2020-04-17 06:36:51 -05:00
|
|
|
> ._card {
|
|
|
|
> .banner {
|
|
|
|
> img {
|
|
|
|
display: block;
|
|
|
|
width: 100%;
|
|
|
|
height: 120px;
|
|
|
|
object-fit: cover;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> ._footer {
|
|
|
|
> * {
|
|
|
|
margin: 0 0.5em;
|
|
|
|
}
|
2020-04-13 10:13:49 -05:00
|
|
|
}
|
2020-04-05 03:55:51 -05:00
|
|
|
}
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
</style>
|