Skip to content

Commit 955b328

Browse files
committed
refactor: update contentlayer (next 14 supported)
1 parent 8caed3b commit 955b328

File tree

6 files changed

+24
-29
lines changed

6 files changed

+24
-29
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ pnpm run dev
6464
>
6565
> After upgrade Auth.js to v5: `NEXTAUTH_URL` has removed from `.env.example`.
6666
67-
> [!CAUTION]
68-
> Errors while the build if you update `remark-gfm` package.
6967

7068
## Roadmap
7169

components/content/mdx-components.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from "react";
22
import NextImage, { ImageProps } from "next/image";
33
import Link from "next/link";
4-
import { useMDXComponent } from "next-contentlayer/hooks";
4+
import { useMDXComponent } from "next-contentlayer2/hooks";
55

66
import { cn } from "@/lib/utils";
77
import { MdxCard } from "@/components/content/mdx-card";

contentlayer.config.js renamed to contentlayer.config.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
import { defineDocumentType, makeSource } from "contentlayer/source-files";
1+
import {
2+
ComputedFields,
3+
defineDocumentType,
4+
makeSource,
5+
} from "contentlayer2/source-files";
26
import rehypeAutolinkHeadings from "rehype-autolink-headings";
37
import rehypePrettyCode from "rehype-pretty-code";
48
import rehypeSlug from "rehype-slug";
59
import remarkGfm from "remark-gfm";
610
import { visit } from "unist-util-visit";
711

8-
/** @type {import('contentlayer/source-files').ComputedFields} */
9-
const computedFields = {
12+
const defaultComputedFields: ComputedFields = {
1013
slug: {
1114
type: "string",
1215
resolve: (doc) => `/${doc._raw.flattenedPath}`,
@@ -34,7 +37,7 @@ export const Doc = defineDocumentType(() => ({
3437
default: true,
3538
},
3639
},
37-
computedFields,
40+
computedFields: defaultComputedFields,
3841
}));
3942

4043
export const Guide = defineDocumentType(() => ({
@@ -62,7 +65,7 @@ export const Guide = defineDocumentType(() => ({
6265
default: false,
6366
},
6467
},
65-
computedFields,
68+
computedFields: defaultComputedFields,
6669
}));
6770

6871
export const Post = defineDocumentType(() => ({
@@ -99,7 +102,7 @@ export const Post = defineDocumentType(() => ({
99102
required: true,
100103
},
101104
},
102-
computedFields,
105+
computedFields: defaultComputedFields,
103106
}));
104107

105108
export const Author = defineDocumentType(() => ({
@@ -123,7 +126,7 @@ export const Author = defineDocumentType(() => ({
123126
required: true,
124127
},
125128
},
126-
computedFields,
129+
computedFields: defaultComputedFields,
127130
}));
128131

129132
export const Page = defineDocumentType(() => ({
@@ -139,7 +142,7 @@ export const Page = defineDocumentType(() => ({
139142
type: "string",
140143
},
141144
},
142-
computedFields,
145+
computedFields: defaultComputedFields,
143146
}));
144147

145148
export default makeSource({

next.config.js

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
// FIX: I changed .mjs to .js
2-
// More info: https://github.com/shadcn-ui/taxonomy/issues/100#issuecomment-1605867844
3-
4-
const { createContentlayerPlugin } = require("next-contentlayer");
1+
const { withContentlayer } = require("next-contentlayer2");
52

63
import("./env.mjs");
74

@@ -12,26 +9,22 @@ const nextConfig = {
129
images: {
1310
remotePatterns: [
1411
{
15-
protocol: 'https',
16-
hostname: 'avatars.githubusercontent.com',
12+
protocol: "https",
13+
hostname: "avatars.githubusercontent.com",
1714
},
1815
{
19-
protocol: 'https',
20-
hostname: 'lh3.googleusercontent.com',
16+
protocol: "https",
17+
hostname: "lh3.googleusercontent.com",
2118
},
2219
{
23-
protocol: 'https',
24-
hostname: 'randomuser.me'
25-
}
20+
protocol: "https",
21+
hostname: "randomuser.me",
22+
},
2623
],
2724
},
2825
experimental: {
2926
serverComponentsExternalPackages: ["@prisma/client"],
3027
},
31-
}
32-
33-
const withContentlayer = createContentlayerPlugin({
34-
// Additional Contentlayer config options
35-
});
28+
};
3629

3730
module.exports = withContentlayer(nextConfig);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "saas-starter",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"private": true,
55
"author": {
66
"name": "mickasmt",

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"**/*.ts",
3232
"**/*.tsx",
3333
".next/types/**/*.ts",
34-
".contentlayer/generated"
34+
".contentlayer/generated",
35+
"contentlayer.config.ts"
3536
],
3637
"exclude": ["node_modules"]
3738
}

0 commit comments

Comments
 (0)