-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
offload loading to other components and use Suspense
- Loading branch information
1 parent
c924e63
commit 0118b38
Showing
3 changed files
with
61 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<template> | ||
<ContentDoc> | ||
<template #not-found> | ||
<div class="text-center py-16"> | ||
<h1 class="text-4xl font-bold mb-4">Document Not Found</h1> | ||
<p class="text-lg mb-4">Sorry, the document you are looking for does not exist.</p> | ||
<NuxtLink to="/" class="text-primary underline">Go back to the homepage</NuxtLink> | ||
</div> | ||
</template> | ||
</ContentDoc> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<template> | ||
<section v-if="postsState?.length" class="mt-8"> | ||
<h2 class="text-2xl font-bold mb-4">Did you also read these? 👀</h2> | ||
<ul> | ||
<li v-for="post in shuffled(postsState.filter((p) => p._path !== $route.path).slice(0, 3))" | ||
:key="post._path"> | ||
<NuxtLink :to="post._path" class="text-primary underline">{{ post.title }}</NuxtLink> | ||
</li> | ||
</ul> | ||
</section> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
interface BlogPost { | ||
_path: string; | ||
title: string; | ||
description?: string; | ||
image?: string; | ||
date?: string; | ||
_file: string; | ||
_dir: string; | ||
} | ||
const postsState = useState<BlogPost[]>("posts", () => []); | ||
const shuffled = <T>(items: T[]): T[] => | ||
items | ||
.map((value: T) => ({ value, sort: Math.random() })) | ||
.sort((a, b) => a.sort - b.sort) | ||
.map(({ value }) => value); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters