Skip to content

Commit

Permalink
Merge pull request #16 from AndrewLester/ssg-sveltekit
Browse files Browse the repository at this point in the history
Add SvelteKit as an option for static_site_generator setting
  • Loading branch information
JamesMGreene authored Aug 17, 2022
2 parents c61e34f + 9ff7f29 commit f71d3d0
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 3 deletions.
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", or "gatsby"'
description: 'Optional static site generator to attempt to configure: "nuxt", "next", "gatsby", or "sveltekit"'
required: false
generator_config_file:
description: 'Optional file path to static site generator configuration file'
Expand Down
15 changes: 15 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14908,6 +14908,20 @@ function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, pat
pathPrefix: path
}
}
case 'sveltekit':
// SvelteKit does not want a trailing slash
if (path.endsWith('/')) {
path = path.slice(0, -1)
}

return {
configurationFile: generatorConfigFile || './svelte.config.js',
blankConfigurationFile: __nccwpck_require__.ab + "sveltekit.js",
properties: {
// Configure a base path
'kit.paths.base': path
}
}
default:
throw `Unsupported static site generator: ${staticSiteGenerator}`
}
Expand Down Expand Up @@ -16429,6 +16443,7 @@ async function main() {
setPagesPath({ staticSiteGenerator, generatorConfigFile, path: siteUrl.pathname })
}
outputPagesBaseUrl(siteUrl)
core.exportVariable('GITHUB_PAGES', 'true')
} catch (error) {
core.setFailed(error)
process.exit(1)
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions dist/sveltekit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Default Pages configuration for SvelteKit
import adapter from '@sveltejs/adapter-auto'

export default {
kit: {
adapter: adapter()
}
}
8 changes: 8 additions & 0 deletions src/blank-configurations/sveltekit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Default Pages configuration for SvelteKit
import adapter from '@sveltejs/adapter-auto'

export default {
kit: {
adapter: adapter()
}
}
9 changes: 9 additions & 0 deletions src/fixtures/sveltekit/blank.expected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Default Pages configuration for SvelteKit
import adapter from '@sveltejs/adapter-auto'

export default {
kit: {
paths: { base: '/docs' },
adapter: adapter()
}
}
1 change: 1 addition & 0 deletions src/fixtures/sveltekit/blank.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// This file is not read by the test suite
11 changes: 11 additions & 0 deletions src/fixtures/sveltekit/default.expected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import adapter from '@sveltejs/adapter-auto'

/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
paths: { base: '/docs' },
adapter: adapter()
}
}

export default config
10 changes: 10 additions & 0 deletions src/fixtures/sveltekit/default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import adapter from '@sveltejs/adapter-auto'

/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter()
}
}

export default config
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ async function main() {
setPagesPath({ staticSiteGenerator, generatorConfigFile, path: siteUrl.pathname })
}
outputPagesBaseUrl(siteUrl)
core.exportVariable('GITHUB_PAGES', 'true')
} catch (error) {
core.setFailed(error)
process.exit(1)
Expand Down
14 changes: 14 additions & 0 deletions src/set-pages-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, pat
pathPrefix: path
}
}
case 'sveltekit':
// SvelteKit does not want a trailing slash
if (path.endsWith('/')) {
path = path.slice(0, -1)
}

return {
configurationFile: generatorConfigFile || './svelte.config.js',
blankConfigurationFile: `${__dirname}/blank-configurations/sveltekit.js`,
properties: {
// Configure a base path
'kit.paths.base': path
}
}
default:
throw `Unsupported static site generator: ${staticSiteGenerator}`
}
Expand Down
2 changes: 1 addition & 1 deletion src/set-pages-path.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { getTempFolder, compareFiles } = require('./test-helpers')
// Get the temp folder
const tempFolder = getTempFolder()

const SUPPORTED_GENERATORS = ['next', 'nuxt', 'gatsby']
const SUPPORTED_GENERATORS = ['next', 'nuxt', 'gatsby', 'sveltekit']
const SUPPORTED_FILE_EXTENSIONS = ['.js', '.cjs', '.mjs']

// Test suite
Expand Down

0 comments on commit f71d3d0

Please sign in to comment.