Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support to Nuxt3 #97

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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']
const IS_BLANK_CONFIG_FILE_REGEX = new RegExp(
'^blank\\.(' + SUPPORTED_FILE_EXTENSIONS.map(ext => ext.slice(1)).join('|') + ')$'
)
Expand Down