refactor(index): remove bottom navigation
This commit is contained in:
parent
e82befa2a2
commit
4646544782
1 changed files with 35 additions and 37 deletions
|
@ -1,55 +1,55 @@
|
|||
---
|
||||
import Breadcrumbs from '@/components/Breadcrumbs.astro'
|
||||
import PostNavigation from '@/components/PostNavigation.astro'
|
||||
import TableOfContents from '@/components/TableOfContents.astro'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Separator } from '@/components/ui/separator'
|
||||
import Layout from '@/layouts/Layout.astro'
|
||||
import { parseAuthors } from '@/lib/server-utils'
|
||||
import { formatDate, readingTime } from '@/lib/utils'
|
||||
import { Icon } from 'astro-icon/components'
|
||||
import { Image } from 'astro:assets'
|
||||
import { type CollectionEntry, getCollection, render } from 'astro:content'
|
||||
import { Image } from "astro:assets";
|
||||
import { type CollectionEntry, getCollection, render } from "astro:content";
|
||||
import Breadcrumbs from "@/components/Breadcrumbs.astro";
|
||||
import PostNavigation from "@/components/PostNavigation.astro";
|
||||
import TableOfContents from "@/components/TableOfContents.astro";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import Layout from "@/layouts/Layout.astro";
|
||||
import { parseAuthors } from "@/lib/server-utils";
|
||||
import { formatDate, readingTime } from "@/lib/utils";
|
||||
import { Icon } from "astro-icon/components";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const posts = (await getCollection('blog'))
|
||||
.filter((post) => !post.data.draft)
|
||||
.sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf())
|
||||
return posts.map((post) => ({
|
||||
params: { id: post.id },
|
||||
props: post,
|
||||
}))
|
||||
const posts = (await getCollection("blog"))
|
||||
.filter((post) => !post.data.draft)
|
||||
.sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf());
|
||||
return posts.map((post) => ({
|
||||
params: { id: post.id },
|
||||
props: post,
|
||||
}));
|
||||
}
|
||||
type Props = CollectionEntry<'blog'>
|
||||
type Props = CollectionEntry<"blog">;
|
||||
|
||||
const posts = (await getCollection('blog'))
|
||||
.filter((post) => !post.data.draft)
|
||||
.sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf())
|
||||
const posts = (await getCollection("blog"))
|
||||
.filter((post) => !post.data.draft)
|
||||
.sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf());
|
||||
|
||||
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 {
|
||||
const postIndex = getPostIndex(id)
|
||||
return postIndex !== -1 && postIndex < posts.length - 1
|
||||
? posts[postIndex + 1]
|
||||
: null
|
||||
const postIndex = getPostIndex(id);
|
||||
return postIndex !== -1 && postIndex < posts.length - 1
|
||||
? posts[postIndex + 1]
|
||||
: null;
|
||||
}
|
||||
|
||||
function getNextPost(id: string): Props | null {
|
||||
const postIndex = getPostIndex(id)
|
||||
return postIndex > 0 ? posts[postIndex - 1] : null
|
||||
const postIndex = getPostIndex(id);
|
||||
return postIndex > 0 ? posts[postIndex - 1] : null;
|
||||
}
|
||||
|
||||
const currentPostId = Astro.params.id
|
||||
const nextPost = getNextPost(currentPostId)
|
||||
const prevPost = getPrevPost(currentPostId)
|
||||
const currentPostId = Astro.params.id;
|
||||
const nextPost = getNextPost(currentPostId);
|
||||
const prevPost = getPrevPost(currentPostId);
|
||||
|
||||
const post = Astro.props
|
||||
const { Content, headings } = await render(post)
|
||||
const post = Astro.props;
|
||||
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}>
|
||||
|
@ -99,8 +99,6 @@ const authors = await parseAuthors(post.data.authors ?? [])
|
|||
<article class="prose col-start-2 max-w-none">
|
||||
<Content />
|
||||
</article>
|
||||
|
||||
<PostNavigation prevPost={prevPost} nextPost={nextPost} />
|
||||
</section>
|
||||
|
||||
<Button
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue