Skip to content

Commit 01c50c3

Browse files
fix: update dependency @nuxt/content to v3 (#132)
BREAKING CHANGE: upgrade to @nuxt/content v3
1 parent 1add749 commit 01c50c3

File tree

7 files changed

+787
-367
lines changed

7 files changed

+787
-367
lines changed

README.md

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,35 +80,54 @@ export default {
8080

8181
This will set `doc.createdAt` and `doc.updatedAt` with the dates from the Git log.
8282

83-
It is also possible to not override the values but instead specify the field names like this:
83+
Now you need to define those fields in your collection schema, otherwise @nuxt/content won't add them to the database.
8484

8585
```js
86-
export default {
87-
modules: [
88-
'@nuxt/content',
89-
['nuxt-content-git', {
90-
createdAtName: 'gitCreatedAt',
91-
updatedAtName: 'gitUpdatedAt',
92-
}],
93-
],
94-
}
86+
// content.config.js
87+
88+
import { defineContentConfig, defineCollection, z } from '@nuxt/content';
89+
90+
export default defineContentConfig({
91+
collections: {
92+
content: defineCollection({
93+
source: '**',
94+
type: 'page',
95+
schema: z.object({
96+
createdAt: z.date(),
97+
updatedAt: z.date(),
98+
}),
99+
}),
100+
},
101+
});
95102
```
96103

97-
Then you can access them via `doc.gitCreatedAt` and `doc.gitUpdatedAt`.
104+
You can override the values via front matter like so:
98105

99-
## Nuxt 2
106+
```md
107+
// content/home.md
100108

101-
For Nuxt 2 you need to add the module _before_ `@nuxt/content`:
109+
---
110+
createdAt: 2020-04-04
111+
updatedAt: 2020-06-06
112+
---
113+
```
114+
115+
It is also possible to adjust the field names like this:
102116

103117
```js
104118
export default {
105119
modules: [
106-
'nuxt-content-git',
107120
'@nuxt/content',
108-
},
121+
['nuxt-content-git', {
122+
createdAtName: 'gitCreatedAt',
123+
updatedAtName: 'gitUpdatedAt',
124+
}],
125+
],
109126
}
110127
```
111128

129+
Update the schema accordingly. Then you can access them via `doc.gitCreatedAt` and `doc.gitUpdatedAt`.
130+
112131
## Deployment
113132

114133
The module uses the Git history to calculate the dates. That is why the history also needs to be checked out when deploying the project to live. During local development the repository is usually deeply cloned. But CI systems like GitHub Actions often only do a shallow clone for performance reasons, which will result in wrong dates.

package.json

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,22 @@
3737
"test": "base test"
3838
},
3939
"dependencies": {
40-
"@dword-design/functions": "^6.0.0",
41-
"@nuxt/kit": "^3.5.3",
42-
"simple-git": "^3.15.1"
40+
"@dword-design/functions": "^6.0.2",
41+
"simple-git": "^3.27.0"
4342
},
4443
"devDependencies": {
45-
"@dword-design/base": "^11.0.0",
44+
"@dword-design/base": "^11.2.10",
4645
"@dword-design/base-config-nuxt-module": "^1.0.0",
47-
"@dword-design/tester": "^2.0.0",
46+
"@dword-design/tester": "^2.0.19",
4847
"@dword-design/tester-plugin-tmp-dir": "^2.1.26",
49-
"@nuxt/content": "^2.6.0",
50-
"axios": "^1.4.0",
51-
"depcheck-package-name": "^3.0.0",
48+
"@nuxt/content": "^3.4.0",
49+
"axios": "^1.8.4",
50+
"depcheck-package-name": "^3.0.1",
5251
"execa": "^9.5.2",
53-
"fs-extra": "^11.1.1",
54-
"nuxt": "^3.5.3",
52+
"fs-extra": "^11.3.0",
53+
"nuxt": "^3.16.2",
5554
"nuxt-dev-ready": "^3.0.0",
56-
"output-files": "^2.0.0",
55+
"output-files": "^2.0.32",
5756
"tree-kill-promise": "^3.0.14"
5857
},
5958
"packageManager": "pnpm@10.8.1+sha512.c50088ba998c67b8ca8c99df8a5e02fd2ae2e2b29aaf238feaa9e124248d3f48f9fb6db2424949ff901cffbb5e0f0cc1ad6aedb602cd29450751d11c35023677",

0 commit comments

Comments
 (0)