Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 3x 12x 12x 12x 12x 12x 12x 1x 12x 12x 12x 2x 2x 2x 12x 12x 11x | export const useArticle = async () => {
const route = useRoute("article");
const { data: related } = useCachedFetch<ArticleSummary[]>(
`/api/articles/${route.params.slug}/related`,
{
lazy: true,
default: () => [],
},
);
const { data: comments } = useCachedFetch<ArticleComments>(
`/api/articles/${route.params.slug}/comments`,
{
key: `article-comments-${route.params.slug}`,
server: false,
lazy: true,
},
);
const { data: authorCounts } = useCachedFetch("/api/authors", {
key: "author-counts",
lazy: true,
default: () => ({}),
transform: (authors): Record<string, number> =>
Object.fromEntries(authors.map(({ value, count }) => [value.id, count])),
});
const request = useCachedFetch<Article>(`/api/articles/${route.params.slug}`);
const { data: article } = request;
useSeoMeta({
title: () => article.value?.seo?.title ?? article.value?.title,
description: () => article.value?.seo?.description ?? article.value?.excerpt,
ogType: "article",
ogImage: () => article.value?.image?.url,
ogImageAlt: () => article.value?.image?.alt,
articlePublishedTime: () => article.value?.publishedAt,
articleModifiedTime: () => article.value?.updatedAt,
robots: () => (article.value?.seo?.noindex ? "noindex" : undefined),
});
useSeoTitleTemplate(() => article.value?.seo?.title);
await useFailOnError(request);
return { article, related, authorCounts, comments };
};
|