Skip to content

Commit

Permalink
docs: fix flatten path
Browse files Browse the repository at this point in the history
  • Loading branch information
kyechan99 committed Oct 12, 2024
1 parent daea909 commit 02efaf7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion apps/www/contentlayer.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const Post = defineDocumentType(() => ({
},
path: {
type: 'string',
resolve: (doc: any) => doc._raw.flattenedPath.replace(/^(docs|project)\//, ''),
resolve: (doc: any) => doc._raw.flattenedPath,
},
postType: { type: 'string', resolve: (doc: any) => doc._raw.sourceFileDir.split('/')[0] },
searchTxt: { type: 'string', resolve: (doc: any) => searchTermOptimization(doc.title) },
Expand Down
16 changes: 4 additions & 12 deletions apps/www/src/app/[...slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import '@/styles/prism.css';
import { notFound } from 'next/navigation';

// import { notFound } from 'next/navigation';
// import { PostLayout } from '@/components/layout';
import { PostLayout } from '@/components/layout';
import { allPosts } from '@/constants/posts';
import { PostType } from '@/types/post';
import { getArticleMetadata } from '@/utils/seo';
Expand All @@ -18,18 +18,10 @@ export const generateMetadata = ({ params }: { params: { slug: string[] } }) =>

const PostPage = ({ params }: { params: { slug: string[] } }) => {
const flattenedPath = params.slug.join('/');
console.log(flattenedPath);
const post = allPosts.find(post => post._raw.flattenedPath === flattenedPath);
return (
<div>
{flattenedPath}
<hr />
{JSON.stringify(post)}
</div>
);
// if (!post) notFound();
if (!post) notFound();

// return <PostLayout post={post} />;
return <PostLayout post={post} />;
};

export default PostPage;

0 comments on commit 02efaf7

Please sign in to comment.