Skip to content

Commit 7191516

Browse files
authored
feat: netlify preset (#3122)
1 parent 86a6a11 commit 7191516

File tree

5 files changed

+53
-0
lines changed

5 files changed

+53
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
title: Netlify
3+
description: Deploy your Content app to Netlify
4+
---
5+
6+
::card
7+
Quick Setup
8+
9+
- Go go Netlify dashboard and create a new project using git repository.
10+
- Go to `Site Configuration` under `Dependency management` and change Node Version to `20.x` or higher.
11+
- Go to `deploys` and retry last deployment.
12+
::
13+
14+
:hr
15+
16+
Nuxt Content projects can be deployed to Netlify with zero configuration. The module will automatically detects Netlify environment and prepare the necessary configuration for Netlify.
17+
18+
All you need to do is to go to Netlify dashboard and create a new project using git repository.
19+
20+
::note
21+
By default Netlify uses Node.js 18.x which is not supported by the module. You need to change the Node.js version in `Site Configuration` under `Dependency management`.
22+
::
23+
24+
That's it :tada:
25+
26+
Checkout:
27+
28+
- [Nuxt Deploy documentation](https://nuxt.com/deploy/netlify)
29+
- [Netlify documentation](https://www.netlify.com/blog/2016/09/29/a-step-by-step-guide-deploying-on-netlify/)

src/presets/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import cloudflare from './cloudflare-pages'
44
import vercel from './vercel'
55
import node from './node'
66
import nuxthub from './nuxthub'
7+
import netlify from './netlify'
78

89
export function findPreset(nuxt: Nuxt) {
910
const preset = nuxt.options.nitro.preset?.replace(/_/g, '-')
@@ -16,6 +17,10 @@ export function findPreset(nuxt: Nuxt) {
1617
return cloudflare
1718
}
1819

20+
if (preset === 'netlify-legacy' || process.env.NETLIFY === 'true') {
21+
return netlify
22+
}
23+
1924
if (preset === 'vercel' || process.env.VERCEL === '1') {
2025
return vercel
2126
}

src/presets/netlify.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { definePreset } from '../utils/preset'
2+
import { logger } from '../utils/dev'
3+
import nodePreset from './node'
4+
5+
export default definePreset({
6+
name: 'netlify',
7+
async setup(options) {
8+
options.database ||= { type: 'sqlite', filename: '/tmp/contents.sqlite' }
9+
},
10+
async setupNitro(nitroConfig, options) {
11+
const database = nitroConfig.runtimeConfig?.content?.database
12+
if (database?.type === 'sqlite' && !database?.filename?.startsWith('/tmp')) {
13+
logger.warn('Deploying sqlite database to Netlify is possible only in `/tmp` directory. Using `/tmp/contents.sqlite` instead.')
14+
database.filename = '/tmp/contents.sqlite'
15+
}
16+
17+
await nodePreset.setupNitro(nitroConfig, options)
18+
},
19+
})

0 commit comments

Comments
 (0)