Skip to content

Commit

Permalink
feat: update article page
Browse files Browse the repository at this point in the history
  • Loading branch information
EvgenyWas committed Jun 7, 2024
1 parent f920c58 commit 89e33b0
Showing 1 changed file with 60 additions and 8 deletions.
68 changes: 60 additions & 8 deletions pages/articles/[topic]/[slug].vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
<template>
<div class="container mb-8">
<article class="article">
<div class="d-flex flex-column justify-center align-center mb-8 mb-md-12">
<h1 class="mb-2 text-h5 text-md-h4 text-center">{{ article?.title }}</h1>
<div class="article-header d-flex flex-column justify-center align-center mb-8 mb-md-12">
<h1 class="mb-2 text-h5 text-md-h4 text-center">
{{ article?.title }}
<VTooltip text="Views of the article">
<template #activator="{ props }">
<span
v-if="stats || !statsPending"
v-bind="props"
class="article-header-title-badge d-inline-flex align-center px-1 text-caption bg-grey rounded-xl"
>
{{ stats?.views }}&nbsp;
<VIcon
icon="fas fa-eye"
size="12"
/>
</span>
</template>
</VTooltip>
</h1>

<p
v-if="article?.author"
class="text-subtitle-1 mb-2"
>
{{ article.author }}
</p>

<NuxtLink
v-if="article?.src"
:to="article.src"
Expand All @@ -18,11 +37,12 @@
>
Source article
</NuxtLink>

<img
v-if="article?.image"
:src="article.image"
:alt="article?.title"
class="article-image w-75"
class="article-header-image w-75"
/>
</div>

Expand All @@ -36,6 +56,21 @@
class="px-0"
tag="section"
>
<VRow v-if="stats || !statsPending">
<VCol class="d-flex flex-column align-center justify-center">
<div class="text-h5 mb-2">Rating overview</div>
<div class="text-h4">
{{ stats?.rate }}
<span class="text-h6 ml-n3">&nbsp;/ {{ MAX_ARTICLE_RATE }}</span>
</div>
<VRating
:model-value="3.5"
color="yellow-darken-3"
/>
<div class="px-3">{{ stats?.ratings }} ratings</div>
</VCol>
</VRow>

<VRow>
<VCol cols="6">
<VBtn
Expand Down Expand Up @@ -79,6 +114,7 @@
</template>

<script setup lang="ts">
import { MAX_ARTICLE_RATE } from '~/configs/properties';
import type { ArticleContent } from '~/types/responses';
type ArticlePageTransition = 'slide-left' | 'slide-right' | 'fade';
Expand Down Expand Up @@ -108,6 +144,14 @@ if (!article.value || error.value) {
useSeoMeta({ title: article.value?.title, description: article.value?.description });
// TODO: add stats endpoint
const { data: stats, pending: statsPending } = await useLazyAsyncData<{ views: number; rate: number; ratings: number }>(
() => {
return new Promise((resolve) => setTimeout(() => resolve({ views: 200, rate: 3.3, ratings: 3360 }), 2000));
},
{ deep: false },
);
const { data: siblings } = await useLazyAsyncData(
() =>
queryContent<ArticleContent>()
Expand Down Expand Up @@ -146,11 +190,19 @@ onBeforeRouteLeave((_, from) => {
}
.article {
&-image {
max-width: 100%;
height: auto;
max-height: 500px;
object-fit: contain;
&-header {
&-image {
max-width: 100%;
height: auto;
max-height: 500px;
object-fit: contain;
}
&-title {
&-badge {
transform: translateY(-5px);
}
}
}
ol {
Expand Down

0 comments on commit 89e33b0

Please sign in to comment.