Skip to content

Commit

Permalink
docs(next): #257 add tabs for all kinds of next.js configuration
Browse files Browse the repository at this point in the history
Closes: #257
  • Loading branch information
sdorra committed Aug 31, 2024
1 parent 8f0de86 commit 4199676
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 5 deletions.
39 changes: 35 additions & 4 deletions docs/adapter/next.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ After installation we have to add a path alias for the generated collections to

Now we can add the Content Collections plugin to the Next.js config:

<Tabs groupId="typof-next-config" items={["next.config.mjs", "next.config.js", "next.config.ts"]} persist>
<Tab value="next.config.mjs">

```js
import { withContentCollections } from "@content-collections/next";

/** @type {import('next').NextConfig} */
const nextConfig = {
// your next.js config
};

export default withContentCollections(nextConfig);
```
</Tab>
<Tab value="next.config.js">

```js
const { withContentCollections } = require("@content-collections/next");

Expand All @@ -53,6 +69,21 @@ const nextConfig = {

module.exports = withContentCollections(nextConfig);
```
</Tab>
<Tab value="next.config.ts">

```ts
import type { NextConfig } from "next";
import { withContentCollections } from "@content-collections/next";

const nextConfig: NextConfig = {
/* config options here */
};

export default withContentCollections(nextConfig);
```
</Tab>
</Tabs>

<Callout type="warn" title="Warning">

Expand Down Expand Up @@ -104,7 +135,7 @@ The function accepts one argument, an options object with the following properti
#### Example

```js
const { createContentCollectionPlugin } = require("@content-collections/next");
import { createContentCollectionPlugin } from "@content-collections/next";

/** @type {import('next').NextConfig} */
const nextConfig = {
Expand All @@ -115,7 +146,7 @@ const withPlugin = createContentCollectionPlugin({
configPath: "./config/content-collections.config.ts",
});

module.exports = withPlugin(nextConfig);
export default withPlugin(nextConfig);
```

### `withContentCollections`
Expand All @@ -125,12 +156,12 @@ The function takes a single argument, a Next.js configuration object, and return
#### Example

```js
const { withContentCollections } = require("@content-collections/next");
import { withContentCollections } from "@content-collections/next";

/** @type {import('next').NextConfig} */
const nextConfig = {
// your next.js config
};

module.exports = withContentCollections(nextConfig);
export default withContentCollections(nextConfig);
```
33 changes: 32 additions & 1 deletion docs/quickstart/next.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,23 @@ This is necessary because we will generate the files in the `.content-collection
</div>
<div className="step">

Modify your `next.config.js`:
Modify your Next.js configuration:

<Tabs groupId="typof-next-config" items={["next.config.mjs", "next.config.js", "next.config.ts"]} persist>
<Tab value="next.config.mjs">

```js
import { withContentCollections } from "@content-collections/next";

/** @type {import('next').NextConfig} */
const nextConfig = {
// your next.js config
};

export default withContentCollections(nextConfig);
```
</Tab>
<Tab value="next.config.js">

```js
const { withContentCollections } = require("@content-collections/next");
Expand All @@ -54,6 +70,21 @@ const nextConfig = {

module.exports = withContentCollections(nextConfig);
```
</Tab>
<Tab value="next.config.ts">

```ts
import type { NextConfig } from "next";
import { withContentCollections } from "@content-collections/next";

const nextConfig: NextConfig = {
/* config options here */
};

export default withContentCollections(nextConfig);
```
</Tab>
</Tabs>

This will add content collections to the build of your next.js app.
For more details on the Next.js adapter, refer to the [documentation](/docs/adapter/next).
Expand Down

0 comments on commit 4199676

Please sign in to comment.