Skip to content

Commit 87d4b6c

Browse files
committed
refactor: migrate content management from contentlayer to content-collections
1 parent a78d130 commit 87d4b6c

File tree

17 files changed

+7030
-8317
lines changed

17 files changed

+7030
-8317
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ next-env.d.ts
4040
/.react-email/
4141

4242
.vscode
43-
.contentlayer
43+
.content-collections

app/(docs)/docs/[[...slug]]/page.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { notFound } from "next/navigation";
2-
import { allDocs } from "contentlayer/generated";
2+
import { allDocs } from "content-collections";
33

44
import { getTableOfContents } from "@/lib/toc";
55
import { Mdx } from "@/components/content/mdx-components";
@@ -20,7 +20,8 @@ interface DocPageProps {
2020
}
2121

2222
async function getDocFromParams(params) {
23-
const slug = params.slug?.join("/") || "";
23+
const slug = params.slug?.join("/") || "index";
24+
2425
const doc = allDocs.find((doc) => doc.slugAsParams === slug);
2526

2627
if (!doc) return null;
@@ -58,11 +59,12 @@ export default async function DocPage({ params }: DocPageProps) {
5859
notFound();
5960
}
6061

61-
const toc = await getTableOfContents(doc.body.raw);
62+
const toc = await getTableOfContents(doc.content);
6263

6364
const images = await Promise.all(
6465
doc.images.map(async (src: string) => ({
6566
src,
67+
alt: "Image",
6668
blurDataURL: await getBlurDataURL(src),
6769
})),
6870
);
@@ -72,7 +74,7 @@ export default async function DocPage({ params }: DocPageProps) {
7274
<div className="mx-auto w-full min-w-0">
7375
<DocsPageHeader heading={doc.title} text={doc.description} />
7476
<div className="pb-4 pt-11">
75-
<Mdx code={doc.body.code} images={images} />
77+
<Mdx code={doc.body} images={images} />
7678
</div>
7779
<hr className="my-4 md:my-6" />
7880
<DocsPager doc={doc} />

app/(docs)/guides/[slug]/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { allGuides } from "contentlayer/generated";
1+
import { allGuides } from "content-collections";
22
import Link from "next/link";
33
import { notFound } from "next/navigation";
44

@@ -53,14 +53,14 @@ export default async function GuidePage({
5353
notFound();
5454
}
5555

56-
const toc = await getTableOfContents(guide.body.raw);
56+
const toc = await getTableOfContents(guide.body);
5757

5858
return (
5959
<MaxWidthWrapper>
6060
<div className="relative py-6 lg:grid lg:grid-cols-[1fr_300px] lg:gap-10 lg:py-10 xl:gap-20">
6161
<div>
6262
<DocsPageHeader heading={guide.title} text={guide.description} />
63-
<Mdx code={guide.body.code} />
63+
<Mdx code={guide.body} />
6464
<hr className="my-4" />
6565
<div className="flex justify-center py-6 lg:py-10">
6666
<Link

app/(docs)/guides/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Link from "next/link";
2-
import { allGuides } from "contentlayer/generated";
2+
import { allGuides } from "content-collections";
33
import { compareDesc } from "date-fns";
44

55
import { formatDate } from "@/lib/utils";

app/(marketing)/(blog-post)/blog/[slug]/page.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { notFound } from "next/navigation";
2-
import { allPosts } from "contentlayer/generated";
2+
import { allPosts } from "content-collections";
33

44
import { Mdx } from "@/components/content/mdx-components";
55

@@ -72,13 +72,14 @@ export default async function PostPage({
7272
)) ||
7373
[];
7474

75-
const toc = await getTableOfContents(post.body.raw);
75+
const toc = await getTableOfContents(post.content);
7676

7777
const [thumbnailBlurhash, images] = await Promise.all([
7878
getBlurDataURL(post.image),
7979
await Promise.all(
8080
post.images.map(async (src: string) => ({
8181
src,
82+
alt: "image",
8283
blurDataURL: await getBlurDataURL(src),
8384
})),
8485
),
@@ -140,7 +141,7 @@ export default async function PostPage({
140141
sizes="(max-width: 768px) 770px, 1000px"
141142
/>
142143
<div className="px-[.8rem] pb-10 md:px-8">
143-
<Mdx code={post.body.code} images={images} />
144+
<Mdx code={post.body} images={images} />
144145
</div>
145146
</div>
146147

app/(marketing)/[slug]/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { notFound } from "next/navigation";
2-
import { allPages } from "contentlayer/generated";
2+
import { allPages } from "content-collections";
33

44
import { Mdx } from "@/components/content/mdx-components";
55

@@ -49,6 +49,7 @@ export default async function PagePage({
4949
const images = await Promise.all(
5050
page.images.map(async (src: string) => ({
5151
src,
52+
alt: "image",
5253
blurDataURL: await getBlurDataURL(src),
5354
})),
5455
);
@@ -64,7 +65,7 @@ export default async function PagePage({
6465
)}
6566
</div>
6667
<hr className="my-4" />
67-
<Mdx code={page.body.code} images={images} />
68+
<Mdx code={page.body} images={images} />
6869
</article>
6970
);
7071
}

app/(marketing)/blog/category/[slug]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Metadata } from "next";
22
import { notFound } from "next/navigation";
3-
import { allPosts } from "contentlayer/generated";
3+
import { allPosts } from "content-collections";
44

55
import { BLOG_CATEGORIES } from "@/config/blog";
66
import { constructMetadata, getBlurDataURL } from "@/lib/utils";

app/(marketing)/blog/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { allPosts } from "contentlayer/generated";
1+
import { allPosts } from "content-collections";
22

33
import { constructMetadata, getBlurDataURL } from "@/lib/utils";
44
import { BlogPosts } from "@/components/content/blog-posts";

components/content/blog-card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Link from "next/link";
2-
import { Post } from "contentlayer/generated";
2+
import { Post } from "content-collections";
33

44
import { cn, formatDate, placeholderBlurhash } from "@/lib/utils";
55
import BlurImage from "@/components/shared/blur-image";

components/content/blog-posts.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Post } from "@/.contentlayer/generated";
1+
import { Post } from "content-collections";
22

33
import { BlogCard } from "./blog-card";
44

0 commit comments

Comments
 (0)