117 lines
3.2 KiB
Vue
117 lines
3.2 KiB
Vue
<script setup lang="ts">
|
||||
|
|
const route = useRoute()
|
|||
|
|
const { getBlogPostBySlug } = useNoroData()
|
|||
|
|
|
|||
|
|
const slug = computed(() => route.params.slug as string)
|
|||
|
|
const post = computed(() => getBlogPostBySlug(slug.value))
|
|||
|
|
|
|||
|
|
watchEffect(() => {
|
|||
|
|
if (!post.value) {
|
|||
|
|
throw createError({ statusCode: 404, statusMessage: 'مطلب یافت نشد' })
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
const contentParagraphs = computed(() =>
|
|||
|
|
post.value?.content?.split('\n\n').filter(Boolean) ?? []
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
function formatDate(value?: string) {
|
|||
|
|
if (!value) return ''
|
|||
|
|
return new Intl.DateTimeFormat('fa-IR', {
|
|||
|
|
year: 'numeric',
|
|||
|
|
month: 'long',
|
|||
|
|
day: 'numeric'
|
|||
|
|
}).format(new Date(value))
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
useHead({
|
|||
|
|
title: computed(() =>
|
|||
|
|
post.value?.seoTitle || (post.value ? `${post.value.title} — استودیو نورو` : 'وبلاگ')
|
|||
|
|
),
|
|||
|
|
meta: computed(() => [
|
|||
|
|
{
|
|||
|
|
name: 'description',
|
|||
|
|
content:
|
|||
|
|
post.value?.seoDescription ||
|
|||
|
|
post.value?.excerpt ||
|
|||
|
|
'مقالات استودیو نورو'
|
|||
|
|
}
|
|||
|
|
])
|
|||
|
|
})
|
|||
|
|
</script>
|
|||
|
|
|
|||
|
|
<template>
|
|||
|
|
<div v-if="post">
|
|||
|
|
<section class="relative overflow-hidden border-b border-noro-border">
|
|||
|
|
<GlowBackground />
|
|||
|
|
<div class="noro-container relative py-12 sm:py-16">
|
|||
|
|
<NuxtLink
|
|||
|
|
to="/blog"
|
|||
|
|
class="mb-8 inline-flex items-center gap-2 text-sm text-noro-muted transition hover:text-noro-brand"
|
|||
|
|
>
|
|||
|
|
<span aria-hidden="true">→</span>
|
|||
|
|
بازگشت به وبلاگ
|
|||
|
|
</NuxtLink>
|
|||
|
|
|
|||
|
|
<p
|
|||
|
|
v-if="post.publishedAt"
|
|||
|
|
class="text-sm text-noro-muted"
|
|||
|
|
>
|
|||
|
|
{{ formatDate(post.publishedAt) }}
|
|||
|
|
</p>
|
|||
|
|
<h1 class="mt-3 max-w-4xl text-3xl font-bold text-noro-text sm:text-4xl lg:text-5xl">
|
|||
|
|
{{ post.title }}
|
|||
|
|
</h1>
|
|||
|
|
<p
|
|||
|
|
v-if="post.excerpt"
|
|||
|
|
class="mt-5 max-w-3xl text-lg leading-8 text-noro-muted"
|
|||
|
|
>
|
|||
|
|
{{ post.excerpt }}
|
|||
|
|
</p>
|
|||
|
|
</div>
|
|||
|
|
</section>
|
|||
|
|
|
|||
|
|
<section class="noro-section">
|
|||
|
|
<div class="noro-container">
|
|||
|
|
<div class="mx-auto max-w-3xl">
|
|||
|
|
<div
|
|||
|
|
v-if="post.coverUrl"
|
|||
|
|
class="mb-10 overflow-hidden rounded-2xl border border-noro-border"
|
|||
|
|
>
|
|||
|
|
<img
|
|||
|
|
:src="post.coverUrl"
|
|||
|
|
:alt="post.title"
|
|||
|
|
class="aspect-[16/10] w-full object-cover"
|
|||
|
|
decoding="async"
|
|||
|
|
>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div class="space-y-6 text-base leading-8 text-noro-muted">
|
|||
|
|
<p
|
|||
|
|
v-for="(paragraph, index) in contentParagraphs"
|
|||
|
|
:key="index"
|
|||
|
|
class="whitespace-pre-line"
|
|||
|
|
>
|
|||
|
|
{{ paragraph }}
|
|||
|
|
</p>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
</section>
|
|||
|
|
|
|||
|
|
<section class="border-t border-noro-border bg-noro-surface/50 py-16">
|
|||
|
|
<div class="noro-container text-center">
|
|||
|
|
<h2 class="text-2xl font-bold text-noro-text">
|
|||
|
|
برای پروژه بعدی آمادهاید؟
|
|||
|
|
</h2>
|
|||
|
|
<p class="mt-3 text-noro-muted">
|
|||
|
|
با ما در تماس باشید تا درباره نیازهای برند و محتوای شما صحبت کنیم.
|
|||
|
|
</p>
|
|||
|
|
<UiButton to="/contact" class="mt-6">
|
|||
|
|
تماس با ما
|
|||
|
|
</UiButton>
|
|||
|
|
</div>
|
|||
|
|
</section>
|
|||
|
|
</div>
|
|||
|
|
</template>
|