refactor(index): remove bottom navigation

This commit is contained in:
z0x 2025-04-24 21:22:31 -04:00
parent e82befa2a2
commit 4646544782

View file

@ -1,55 +1,55 @@
--- ---
import Breadcrumbs from '@/components/Breadcrumbs.astro' import { Image } from "astro:assets";
import PostNavigation from '@/components/PostNavigation.astro' import { type CollectionEntry, getCollection, render } from "astro:content";
import TableOfContents from '@/components/TableOfContents.astro' import Breadcrumbs from "@/components/Breadcrumbs.astro";
import { Button } from '@/components/ui/button' import PostNavigation from "@/components/PostNavigation.astro";
import { Separator } from '@/components/ui/separator' import TableOfContents from "@/components/TableOfContents.astro";
import Layout from '@/layouts/Layout.astro' import { Button } from "@/components/ui/button";
import { parseAuthors } from '@/lib/server-utils' import { Separator } from "@/components/ui/separator";
import { formatDate, readingTime } from '@/lib/utils' import Layout from "@/layouts/Layout.astro";
import { Icon } from 'astro-icon/components' import { parseAuthors } from "@/lib/server-utils";
import { Image } from 'astro:assets' import { formatDate, readingTime } from "@/lib/utils";
import { type CollectionEntry, getCollection, render } from 'astro:content' import { Icon } from "astro-icon/components";
export async function getStaticPaths() { export async function getStaticPaths() {
const posts = (await getCollection('blog')) const posts = (await getCollection("blog"))
.filter((post) => !post.data.draft) .filter((post) => !post.data.draft)
.sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf()) .sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf());
return posts.map((post) => ({ return posts.map((post) => ({
params: { id: post.id }, params: { id: post.id },
props: post, props: post,
})) }));
} }
type Props = CollectionEntry<'blog'> type Props = CollectionEntry<"blog">;
const posts = (await getCollection('blog')) const posts = (await getCollection("blog"))
.filter((post) => !post.data.draft) .filter((post) => !post.data.draft)
.sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf()) .sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf());
function getPostIndex(id: string): number { function getPostIndex(id: string): number {
return posts.findIndex((post) => post.id === id) return posts.findIndex((post) => post.id === id);
} }
function getPrevPost(id: string): Props | null { function getPrevPost(id: string): Props | null {
const postIndex = getPostIndex(id) const postIndex = getPostIndex(id);
return postIndex !== -1 && postIndex < posts.length - 1 return postIndex !== -1 && postIndex < posts.length - 1
? posts[postIndex + 1] ? posts[postIndex + 1]
: null : null;
} }
function getNextPost(id: string): Props | null { function getNextPost(id: string): Props | null {
const postIndex = getPostIndex(id) const postIndex = getPostIndex(id);
return postIndex > 0 ? posts[postIndex - 1] : null return postIndex > 0 ? posts[postIndex - 1] : null;
} }
const currentPostId = Astro.params.id const currentPostId = Astro.params.id;
const nextPost = getNextPost(currentPostId) const nextPost = getNextPost(currentPostId);
const prevPost = getPrevPost(currentPostId) const prevPost = getPrevPost(currentPostId);
const post = Astro.props const post = Astro.props;
const { Content, headings } = await render(post) const { Content, headings } = await render(post);
const authors = await parseAuthors(post.data.authors ?? []) const authors = await parseAuthors(post.data.authors ?? []);
--- ---
<Layout title={post.data.title} description={post.data.description}> <Layout title={post.data.title} description={post.data.description}>
@ -99,8 +99,6 @@ const authors = await parseAuthors(post.data.authors ?? [])
<article class="prose col-start-2 max-w-none"> <article class="prose col-start-2 max-w-none">
<Content /> <Content />
</article> </article>
<PostNavigation prevPost={prevPost} nextPost={nextPost} />
</section> </section>
<Button <Button