Files
folio/app/pages/writing/[...slug].vue
T

171 lines
5.6 KiB
Vue
Raw Normal View History

2026-04-29 23:06:11 -05:00
<script lang="ts" setup>
2026-07-30 09:21:34 -05:00
import {
DEFAULT_IMAGE,
SITE_NAME,
SITE_URL,
personId,
websiteId,
} from '~/utils/site';
2026-04-29 23:06:11 -05:00
const route = useRoute();
2026-07-30 09:21:34 -05:00
const articleUrl = `${SITE_URL}${route.path}`;
2026-06-28 18:50:53 -05:00
const webpageId = `${articleUrl}#webpage`;
const articleId = `${articleUrl}#article`;
2026-07-30 09:21:34 -05:00
const blogId = `${SITE_URL}/writing#blog`;
2026-08-22 11:59:33 -05:00
const contentPath =
'/' +
(Array.isArray(route.params.slug)
? route.params.slug.join('/')
: String(route.params.slug ?? ''));
2026-04-29 23:06:11 -05:00
const { data: page } = await useAsyncData(route.path, () => {
2026-08-22 11:59:33 -05:00
return queryCollection('writing').path(contentPath).first();
2026-04-29 23:06:11 -05:00
});
if (!page.value) {
throw createError({ statusCode: 404, statusMessage: 'Page Not Found' });
}
2026-07-30 09:21:34 -05:00
const articleTitle = page.value.title;
const articleDescription = page.value.description;
2026-04-29 23:06:11 -05:00
useSeoMeta({
2026-07-30 09:21:34 -05:00
title: articleTitle,
ogTitle: articleTitle,
description: articleDescription,
ogDescription: articleDescription,
ogUrl: articleUrl,
ogType: 'article',
ogImage: DEFAULT_IMAGE,
ogImageAlt: articleTitle,
twitterCard: 'summary',
twitterTitle: articleTitle,
twitterDescription: articleDescription,
twitterImage: DEFAULT_IMAGE,
articlePublishedTime: new Date(page.value.date).toISOString(),
articleModifiedTime: new Date(page.value.date).toISOString(),
articleAuthor: [SITE_NAME],
2026-04-29 23:06:11 -05:00
});
2026-06-22 00:44:50 -05:00
useHead({
2026-07-30 09:21:34 -05:00
link: [{ rel: 'canonical', href: articleUrl }],
2026-06-22 00:44:50 -05:00
script: [
{
key: 'json-ld-article',
type: 'application/ld+json',
innerHTML: JSON.stringify({
'@context': 'https://schema.org',
2026-06-28 18:50:53 -05:00
'@graph': [
{
'@type': 'WebPage',
'@id': webpageId,
url: articleUrl,
2026-07-30 09:21:34 -05:00
name: articleTitle,
description: articleDescription,
2026-06-28 18:50:53 -05:00
inLanguage: 'en-US',
isPartOf: { '@id': websiteId },
breadcrumb: { '@id': `${articleUrl}#breadcrumb` },
mainEntity: { '@id': articleId },
},
{
'@type': 'Blog',
'@id': blogId,
2026-07-30 09:21:34 -05:00
url: `${SITE_URL}/writing`,
2026-06-28 18:50:53 -05:00
name: 'Jaron Pate Writing',
inLanguage: 'en-US',
isPartOf: { '@id': websiteId },
2026-07-30 09:21:34 -05:00
publisher: {
'@type': 'Person',
'@id': personId,
name: SITE_NAME,
},
2026-06-28 18:50:53 -05:00
},
{
'@type': 'BlogPosting',
'@id': articleId,
url: articleUrl,
2026-07-30 09:21:34 -05:00
headline: articleTitle,
description: articleDescription,
2026-06-28 18:50:53 -05:00
datePublished: new Date(page.value.date).toISOString(),
dateModified: new Date(page.value.date).toISOString(),
image: {
'@type': 'ImageObject',
'@id': `${articleUrl}#article-image`,
2026-07-30 09:21:34 -05:00
url: DEFAULT_IMAGE,
2026-06-28 18:50:53 -05:00
},
inLanguage: 'en-US',
isPartOf: { '@id': blogId },
mainEntityOfPage: { '@id': webpageId },
2026-07-30 09:21:34 -05:00
author: {
'@type': 'Person',
'@id': personId,
name: SITE_NAME,
url: SITE_URL,
},
publisher: {
'@type': 'Person',
'@id': personId,
name: SITE_NAME,
},
2026-06-28 18:50:53 -05:00
},
{
'@type': 'BreadcrumbList',
'@id': `${articleUrl}#breadcrumb`,
itemListElement: [
{
'@type': 'ListItem',
position: 1,
name: 'Home',
2026-07-30 09:21:34 -05:00
item: SITE_URL,
2026-06-28 18:50:53 -05:00
},
{
'@type': 'ListItem',
position: 2,
name: 'Writing',
2026-07-30 09:21:34 -05:00
item: `${SITE_URL}/writing`,
2026-06-28 18:50:53 -05:00
},
{
'@type': 'ListItem',
position: 3,
2026-07-30 09:21:34 -05:00
name: articleTitle,
2026-06-28 18:50:53 -05:00
item: articleUrl,
},
],
},
],
2026-06-22 00:44:50 -05:00
}),
},
],
});
2026-08-22 11:59:33 -05:00
const formatDate = (date: Date | string) => {
return new Date(date).toLocaleDateString('en-US', {
month: 'long',
day: 'numeric',
year: 'numeric',
timeZone: 'UTC',
});
};
definePageMeta({
layout: false,
});
2026-04-29 23:06:11 -05:00
</script>
<template>
2026-08-22 11:59:33 -05:00
<NuxtLayout
name="main"
:title="page.title"
:description="formatDate(page.date)"
>
<article v-if="page">
<div class="article-body">
<p v-if="page.description">
<strong>{{ page.description }}</strong>
</p>
<ContentRenderer :value="page" />
</div>
</article>
</NuxtLayout>
2026-04-29 23:06:11 -05:00
</template>