Skip to content

Commit 342f774

Browse files
committed
Merge branch 'main' of github.com:contentlayerdev/contentlayer
2 parents 727c5cc + 2588c02 commit 342f774

File tree

97 files changed

+2580
-525
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+2580
-525
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@typescript-eslint/no-non-null-assertion": "off",
2424
"@typescript-eslint/no-var-requires": "off",
2525
"@typescript-eslint/explicit-module-boundary-types": "off",
26+
"@typescript-eslint/no-empty-function": "off",
2627
"@typescript-eslint/no-unused-vars": ["warn", { "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" }]
2728
}
2829
}

.github/workflows/ci.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
build-example-next-contentlayer-example:
3232
strategy:
3333
matrix:
34-
node-version: [14, 16, 17, 18]
34+
node-version: [17, 18] # `app` dir requires 17+
3535
os: [ubuntu-latest, windows-latest]
3636
runs-on: ${{ matrix.os }}
3737
steps:
@@ -40,6 +40,18 @@ jobs:
4040
- run: yarn build
4141
working-directory: examples/next-contentlayer-example
4242

43+
build-example-next-rsc-dynamic-example:
44+
strategy:
45+
matrix:
46+
node-version: [17, 18] # `app` dir requires 17+
47+
os: [ubuntu-latest, windows-latest]
48+
runs-on: ${{ matrix.os }}
49+
steps:
50+
- uses: schickling-actions/checkout-and-install@main
51+
- run: yarn build
52+
- run: yarn build
53+
working-directory: examples/next-rsc-dynamic
54+
4355
build-example-node-script:
4456
strategy:
4557
matrix:

examples/next-rsc-dynamic/.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules
2+
dist
3+
.next
4+
.contentlayer
5+
yarn.lock
6+
.DS_Store
7+
8+
nextjs-repo*
9+
.vercel
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"typescript.tsdk": "node_modules/typescript/lib",
3+
"typescript.enablePromptUseWorkspaceTsdk": true
4+
}

examples/next-rsc-dynamic/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Next.js Contentlayer Example
2+
3+
## Demo
4+
5+
View the deployed project: [Demo](https://next-contentlayer-example.vercel.app/)
6+
7+
## Try it Now
8+
9+
[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-908a85?logo=gitpod)](http://gitpod.io/#https://github.com/contentlayerdev/next-contentlayer-example)
10+
11+
## Local Installation
12+
13+
Clone the project:
14+
15+
git clone git@github.com:contentlayerdev/next-contentlayer-example.git
16+
17+
Install dependencies:
18+
19+
yarn
20+
21+
Run dev server:
22+
23+
yarn dev
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { allPosts } from 'contentlayer/generated'
2+
3+
export default function Head({ params }: { params: { slug: string[] } }) {
4+
const slug = params.slug.join('/')
5+
const post = allPosts.find((post) => post._raw.flattenedPath === slug)
6+
7+
return (
8+
<>
9+
<title>{post?.url}</title>
10+
</>
11+
)
12+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { allPosts } from 'contentlayer/generated'
2+
3+
export const generateStaticParams = async () => allPosts.map((post) => ({ slug: post._raw.flattenedPath.split('/') }))
4+
5+
const PostLayout = async ({ params }: { params: { slug: string[]; tag: string } }) => {
6+
const slug = params.slug.join('/')
7+
const post = allPosts.find((post) => post._raw.flattenedPath === slug)
8+
9+
if (post === undefined) {
10+
return <div>Post not found ({slug})</div>
11+
}
12+
13+
return (
14+
<article className="py-8 mx-auto max-w-xl">
15+
<div className="mb-8 text-center">
16+
<h1>{post.url}</h1>
17+
</div>
18+
<div dangerouslySetInnerHTML={{ __html: post.body.html }} />
19+
</article>
20+
)
21+
}
22+
23+
export default PostLayout
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import '../styles/globals.css'
2+
3+
import { Header } from '../components/Header'
4+
5+
export default function RootLayout({ children }: { children: React.ReactNode }) {
6+
return (
7+
<html>
8+
<head>
9+
<title>Contentlayer Next.js Example</title>
10+
<link rel="icon" type="image/x-icon" href="/favicon.png" />
11+
</head>
12+
<body>
13+
<Header />
14+
<div className="px-6">{children}</div>
15+
</body>
16+
</html>
17+
)
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Link from 'next/link'
2+
import { allPosts, Post } from 'contentlayer/generated'
3+
4+
export default async function Home({ params }: { params: { tag: string } }) {
5+
return (
6+
<div className="py-8 mx-auto max-w-xl">
7+
<h1 className="mb-8 text-3xl font-bold text-center">Next.js docs</h1>
8+
<p className="">Branch/Tag: static</p>
9+
10+
{allPosts.map((post, idx) => (
11+
<div key={idx}>
12+
<Link href={'/' + post.url}>{post.url}</Link>
13+
</div>
14+
// <PostCard key={idx} {...post} />
15+
))}
16+
</div>
17+
)
18+
}

0 commit comments

Comments
 (0)