feat: multiple changes

Signed-off-by: Avior <git@avior.me>
This commit is contained in:
2024-09-09 14:27:46 +02:00
parent d8f203f434
commit 3e91597dca
31 changed files with 216 additions and 223 deletions

View File

@ -53,14 +53,14 @@ async function updateRoutes(output: string, routes: Array<string>) {
let file = baseFile
file += `\n\nexport type Routes = ${routes.map((it) => `'${it}'`).join(' | ')}`
file += '\n\nexport default function route(route: Routes, query?: Record<string, string | number>) {'
file +=
'\n\nexport default function route(route: Routes, query?: Record<string, string | number>) {'
file += '\n\treturn formatRoute(route, query)'
file += '\n}\n'
await fs.writeFile(output, file)
}
/**
* format the path back to an url usable by the app
*
@ -141,7 +141,6 @@ const integration: () => AstroIntegration = () => ({
await updateRoutes(outputFile, files)
},
'astro:server:setup': async ({ server }) => {
// get the files list
const files = (await Promise.all([
await getFiles(pagesFolder).then((ev) => ev.map((it) => formatPath(pagesFolder, it))),
@ -158,7 +157,7 @@ const integration: () => AstroIntegration = () => ({
let removeExtension = true
let folder = pagesFolder
if(path.startsWith(publicFolder)) {
if (path.startsWith(publicFolder)) {
removeExtension = false
folder = publicFolder
} else if (!path.startsWith(folder)) {
@ -178,7 +177,7 @@ const integration: () => AstroIntegration = () => ({
path = path.replace(/\\/g, '/')
let removeExtension = true
let folder = pagesFolder
if(path.startsWith(publicFolder)) {
if (path.startsWith(publicFolder)) {
removeExtension = false
folder = publicFolder
}