diff --git a/app/posts/[slug]/actions.test.ts b/app/posts/[slug]/actions.test.ts index c710a65..d61bf90 100644 --- a/app/posts/[slug]/actions.test.ts +++ b/app/posts/[slug]/actions.test.ts @@ -1,11 +1,8 @@ -import * as postsActions from '../actions' - -import { fetchPostBySlug, fetchPreviousPost } from './actions' +import { fetchPostBySlug } from './actions' import * as mdx from '@/lib/mdx' import type { Post } from '@/lib/types' import { getMockFrontmatter } from '@/test/mocks/frontmatter' -import { getMockSource } from '@/test/mocks/source' vi.mock('@/lib/mdx') vi.mock('../actions') @@ -56,26 +53,4 @@ describe('/posts/[slug]/actions', () => { }) }) }) - - describe('fetchPreviousPost', () => { - const mockPosts: Post[] = [ - { slug: 'slug-1', ...getMockFrontmatter(), source: getMockSource() }, - { slug: 'slug-2', ...getMockFrontmatter(), source: getMockSource() }, - ] - - it('returns the next index of results returned from fetchPublishedPosts()', async () => { - vi.mocked(postsActions.fetchPublishedPosts).mockResolvedValue(mockPosts) - - const actual = await fetchPreviousPost('slug-1') - expect(actual).toBeTruthy() - expect(actual?.slug).toEqual('slug-2') - }) - - it('returns undefined when the bottom of the list is reached', async () => { - vi.mocked(postsActions.fetchPublishedPosts).mockResolvedValue(mockPosts) - - const actual = await fetchPreviousPost('slug-2') - expect(actual).toBeUndefined() - }) - }) }) diff --git a/app/posts/[slug]/actions.ts b/app/posts/[slug]/actions.ts index 50da01b..09fa2d8 100644 --- a/app/posts/[slug]/actions.ts +++ b/app/posts/[slug]/actions.ts @@ -4,8 +4,6 @@ import path from 'path' import { notFound } from 'next/navigation' -import { fetchPublishedPosts } from '../actions' - import { getPostFromMDX } from '@/lib/mdx' import type { Post } from '@/lib/types' @@ -22,12 +20,3 @@ export async function fetchPostBySlug(slug: string): Promise { } } } - -export async function fetchPreviousPost(slug: string): Promise { - const publishedPosts = await fetchPublishedPosts() - const postIndex = publishedPosts.findIndex((post) => post.slug === slug) - - if (postIndex === publishedPosts.length - 1) return undefined - - return publishedPosts[postIndex + 1] -} diff --git a/app/posts/[slug]/mdx-content.tsx b/app/posts/[slug]/mdx-content.tsx deleted file mode 100644 index 35c47a1..0000000 --- a/app/posts/[slug]/mdx-content.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import Image, { ImageProps } from 'next/image' -import { MDXRemote, type MDXRemoteProps } from 'next-mdx-remote/rsc' -import { HTMLAttributes, PropsWithChildren } from 'react' -import rehypeAutolinkHeadings from 'rehype-autolink-headings' -import rehypePrettyCode from 'rehype-pretty-code' -import rehypeSlug from 'rehype-slug' -import remarkGfm from 'remark-gfm' -import { HighlighterCoreOptions, getSingletonHighlighter } from 'shiki' - -import { TypographyBlockquote, TypographyH1, TypographyH2, TypographyH3, TypographyP } from '@/components/ui/typography' -import { cn } from '@/lib/utils' - -const components: MDXRemoteProps['components'] = { - img: (props: HTMLAttributes) => ( - article image - ), - h1: (props: PropsWithChildren) => , - h2: (props: PropsWithChildren) => , - h3: (props: PropsWithChildren) => , - p: (props: PropsWithChildren) => , - ol: (props: PropsWithChildren) =>
    , - ul: (props: PropsWithChildren) =>