summaryrefslogtreecommitdiff
path: root/packages/integrations/netlify
diff options
context:
space:
mode:
authorGravatar matthewp <matthewp@users.noreply.github.com> 2022-05-11 15:14:43 +0000
committerGravatar github-actions[bot] <github-actions[bot]@users.noreply.github.com> 2022-05-11 15:14:43 +0000
commit3bb07a01e07d818b626c4adbd0a3ad41f1eba44b (patch)
tree47c4134e0c1613a41bd883b5b818d69c50420d75 /packages/integrations/netlify
parentefe4f1a3ef1679bfa2828bd5b63a494354864bc5 (diff)
downloadastro-3bb07a01e07d818b626c4adbd0a3ad41f1eba44b.tar.gz
astro-3bb07a01e07d818b626c4adbd0a3ad41f1eba44b.tar.zst
astro-3bb07a01e07d818b626c4adbd0a3ad41f1eba44b.zip
[ci] format
Diffstat (limited to 'packages/integrations/netlify')
-rw-r--r--packages/integrations/netlify/src/integration-functions.ts2
-rw-r--r--packages/integrations/netlify/src/shared.ts46
2 files changed, 24 insertions, 24 deletions
diff --git a/packages/integrations/netlify/src/integration-functions.ts b/packages/integrations/netlify/src/integration-functions.ts
index 81cb7e9fd..b353220ce 100644
--- a/packages/integrations/netlify/src/integration-functions.ts
+++ b/packages/integrations/netlify/src/integration-functions.ts
@@ -37,7 +37,7 @@ function netlifyFunctions({ dist }: NetlifyFunctionsOptions = {}): AstroIntegrat
buildConfig.server = new URL('./functions/', _config.outDir);
},
'astro:build:done': async ({ routes, dir }) => {
- await createRedirects(routes, dir, entryFile, false);
+ await createRedirects(routes, dir, entryFile, false);
},
},
};
diff --git a/packages/integrations/netlify/src/shared.ts b/packages/integrations/netlify/src/shared.ts
index 3df667f4d..90bd5333b 100644
--- a/packages/integrations/netlify/src/shared.ts
+++ b/packages/integrations/netlify/src/shared.ts
@@ -2,30 +2,30 @@ import type { RouteData } from 'astro';
import fs from 'fs';
export async function createRedirects(
- routes: RouteData[],
- dir: URL,
- entryFile: string,
- edge: boolean
- ) {
- const _redirectsURL = new URL('./_redirects', dir);
- const kind = edge ? 'edge-functions' : 'functions'
+ routes: RouteData[],
+ dir: URL,
+ entryFile: string,
+ edge: boolean
+) {
+ const _redirectsURL = new URL('./_redirects', dir);
+ const kind = edge ? 'edge-functions' : 'functions';
- // Create the redirects file that is used for routing.
- let _redirects = '';
- for (const route of routes) {
- if (route.pathname) {
- _redirects += `
+ // Create the redirects file that is used for routing.
+ let _redirects = '';
+ for (const route of routes) {
+ if (route.pathname) {
+ _redirects += `
${route.pathname} /.netlify/${kind}/${entryFile} 200`;
- } else {
- const pattern =
- '/' + route.segments.map(([part]) => (part.dynamic ? '*' : part.content)).join('/');
- _redirects += `
+ } else {
+ const pattern =
+ '/' + route.segments.map(([part]) => (part.dynamic ? '*' : part.content)).join('/');
+ _redirects += `
${pattern} /.netlify/${kind}/${entryFile} 200`;
- }
- }
+ }
+ }
- // Always use appendFile() because the redirects file could already exist,
- // e.g. due to a `/public/_redirects` file that got copied to the output dir.
- // If the file does not exist yet, appendFile() automatically creates it.
- await fs.promises.appendFile(_redirectsURL, _redirects, 'utf-8');
-} \ No newline at end of file
+ // Always use appendFile() because the redirects file could already exist,
+ // e.g. due to a `/public/_redirects` file that got copied to the output dir.
+ // If the file does not exist yet, appendFile() automatically creates it.
+ await fs.promises.appendFile(_redirectsURL, _redirects, 'utf-8');
+}