0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

[ci] format

This commit is contained in:
ematipico 2023-07-17 14:56:14 +00:00 committed by astrobot-houston
parent 4c93bd8154
commit 7832c4a850
4 changed files with 9 additions and 11 deletions

View file

@ -115,7 +115,6 @@ Once you run `astro build` there will be a `dist/_redirects` file. Netlify will
> **Note**
> You can still include a `public/_redirects` file for manual redirects. Any redirects you specify in the redirects config are appended to the end of your own.
### Edge Middleware with Astro middleware
The `@astrojs/netlify/functions` adapter can automatically create an edge function that will act as "Edge Middleware", from an Astro middleware in your code base.
@ -140,14 +139,14 @@ Optionally, you can create a file recognized by the adapter named `netlify-edge-
Typings require the [`https://edge.netlify.com`](https://docs.netlify.com/edge-functions/api/#reference) types.
> Netlify edge functions run in a Deno environment, so you would need to import types using URLs.
>
>
> You can find more in the [Netlify documentation page](https://docs.netlify.com/edge-functions/api/#runtime-environment)
```ts
// src/netlify-edge-middleware.ts
import type { Context } from "https://edge.netlify.com";
import type { Context } from 'https://edge.netlify.com';
export default function ({ request, context }: { request: Request, context: Context }): object {
export default function ({ request, context }: { request: Request; context: Context }): object {
// do something with request and context
return {
title: "Spider-man's blog",
@ -173,7 +172,6 @@ When you opt-in to this feature, there are a few constraints to note:
- Only `request` and `context` may be used to produce an `Astro.locals` object. Operations like redirects, etc. should be delegated to Astro middleware.
- `Astro.locals` **must be serializable**. Failing to do so will result in a **runtime error**. This means that you **cannot** store complex types like `Map`, `function`, `Set`, etc.
## Usage
[Read the full deployment guide here.](https://docs.astro.build/en/guides/deploy/netlify/)

View file

@ -1,9 +1,9 @@
import type { AstroAdapter, AstroConfig, AstroIntegration, RouteData } from 'astro';
import { extname } from 'node:path';
import type { Args } from './netlify-functions.js';
import { createRedirects } from './shared.js';
import { fileURLToPath } from 'node:url';
import { generateEdgeMiddleware } from './middleware.js';
import type { Args } from './netlify-functions.js';
import { createRedirects } from './shared.js';
export const NETLIFY_EDGE_MIDDLEWARE_FILE = 'netlify-edge-middleware';
export const ASTRO_LOCALS_HEADER = 'x-astro-locals';

View file

@ -1,6 +1,6 @@
import { fileURLToPath, pathToFileURL } from 'node:url';
import { join } from 'node:path';
import { existsSync } from 'node:fs';
import { join } from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { ASTRO_LOCALS_HEADER } from './integration-functions.js';
import { DENO_SHIM } from './shared.js';

View file

@ -1,9 +1,9 @@
import { createRedirectsFromAstroRoutes } from '@astrojs/underscore-redirects';
import type { AstroConfig, RouteData } from 'astro';
import fs from 'node:fs';
import { fileURLToPath } from 'url';
import esbuild from 'esbuild';
import fs from 'node:fs';
import npath from 'path';
import { fileURLToPath } from 'url';
export const DENO_SHIM = `globalThis.process = {
argv: [],