Files
configure-pages/src/set-pages-path.js
T

47 lines
1.3 KiB
JavaScript
Raw Normal View History

const core = require('@actions/core')
const axios = require('axios')
2022-06-17 18:36:26 -07:00
const { ConfigParser } = require('./config-parser')
2022-06-17 18:36:26 -07:00
async function setPagesPath({staticSiteGenerator, path}) {
try {
switch(staticSiteGenerator)
{
case 'nuxt':
var ssConfig = {
filePath:"./nuxt.config.js",
type: "nuxt",
pathName: "router",
subPathName: "base",
2022-06-17 18:36:26 -07:00
newPath: path
}
break;
case 'next':
var ssConfig = {
filePath:"./next.config.js",
type: "next",
2022-06-17 15:13:00 -07:00
pathName: "basePath",
2022-06-17 18:36:26 -07:00
newPath: path
}
break;
case 'gatsby':
var ssConfig = {
filePath: "./gatsby-config.js",
type: "gatsby",
pathName: "pathPrefix",
2022-06-17 18:36:26 -07:00
newPath: path
}
break;
default:
throw "Unknown config type"
}
let configParser = new ConfigParser(ssConfig)
2022-06-17 18:36:26 -07:00
configParser.parse()
} catch (error) {
2022-06-30 12:10:35 -07:00
core.warning(`We were unable to determine how to inject the site metadata into your config. Generated URLs may be incorrect. The base URL for this site should be ${path}. Please ensure your framework is configured to generate relative links appropriately.`, error)
}
}
module.exports = setPagesPath