Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ runs:
main: 'dist/index.js'
inputs:
static_site_generator:
description: 'Optional static site generator to attempt to configure: "nuxt", "next", "gatsby", or "sveltekit"'
description: 'Optional static site generator to attempt to configure: "nuxt", "nuxt3", "next", "gatsby", or "sveltekit"'
required: false
generator_config_file:
description: 'Optional file path to static site generator configuration file'
Expand Down
3 changes: 3 additions & 0 deletions src/blank-configurations/nuxt3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Default Pages configuration for Nuxt3
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({})
15 changes: 15 additions & 0 deletions src/fixtures/nuxt3/async.expected.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
const getAllDynamicRoute = async function () {
const routes = await (async () => {
return ['/posts/hello-world', '/posts/hello-again']
})()
return routes
}

export default defineNuxtConfig({
ssr: false,
app: { baseURL: '/docs/' },
generate: {
routes: await getAllDynamicRoute()
},
})
13 changes: 13 additions & 0 deletions src/fixtures/nuxt3/async.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
const getAllDynamicRoute = async function () {
const routes = await (async () => {
return ['/posts/hello-world', '/posts/hello-again']
})()
return routes
}

export default defineNuxtConfig({
generate: {
routes: await getAllDynamicRoute()
}
})
25 changes: 25 additions & 0 deletions src/fixtures/nuxt3/default.expected.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
ssr: false,
app: {
baseURL: '/docs/' ,
head: {
title: 'nuxt',
htmlAttrs: {
lang: 'en'
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ key: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' }
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
}
},
css: [],
plugins: [],
components: true,
modules: [],
build: {}
})
23 changes: 23 additions & 0 deletions src/fixtures/nuxt3/default.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
app: {
head: {
title: 'nuxt',
htmlAttrs: {
lang: 'en'
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ key: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' }
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
}
},
css: [],
plugins: [],
components: true,
modules: [],
build: {}
})
13 changes: 13 additions & 0 deletions src/set-pages-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, sit
target: 'static'
}
}
case 'nuxt3':
return {
configurationFile: generatorConfigFile || './nuxt.config.ts',
blankConfigurationFile: `${__dirname}/blank-configurations/nuxt3.ts`,
allowWrappingCall: true,
properties: {
// Configure a base path of the app
'app.baseURL': path,

// Set the target to static too
ssr: false
}
}
case 'next':
// Next does not want a trailing slash
path = removeTrailingSlash(path)
Expand Down
4 changes: 2 additions & 2 deletions src/set-pages-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const { getTempFolder, compareFiles } = require('./test-helpers')
// Get the temp folder
const tempFolder = getTempFolder()

const SUPPORTED_GENERATORS = ['next', 'nuxt', 'gatsby', 'sveltekit']
const SUPPORTED_FILE_EXTENSIONS = ['.js', '.cjs', '.mjs']
const SUPPORTED_GENERATORS = ['next', 'nuxt', 'nuxt3', 'gatsby', 'sveltekit']
const SUPPORTED_FILE_EXTENSIONS = ['.js', '.cjs', '.mjs', '.ts']
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will break Nextjs builds that make use of Typescript in its config with next.config.ts files. This is because the project uses espree to read and parse and modify configuration files and espree doesn't support typescript files. Besides, shouldn't this problem also happen with nuxt? I haven't checked.

const IS_BLANK_CONFIG_FILE_REGEX = new RegExp(
'^blank\\.(' + SUPPORTED_FILE_EXTENSIONS.map(ext => ext.slice(1)).join('|') + ')$'
)
Expand Down