diff options
Diffstat (limited to 'packages/integrations/netlify/test/hosted/hosted-astro-project/src')
6 files changed, 37 insertions, 0 deletions
diff --git a/packages/integrations/netlify/test/hosted/hosted-astro-project/src/assets/penguin.png b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/assets/penguin.png Binary files differnew file mode 100644 index 000000000..218acde5b --- /dev/null +++ b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/assets/penguin.png diff --git a/packages/integrations/netlify/test/hosted/hosted-astro-project/src/env.d.ts b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/env.d.ts new file mode 100644 index 000000000..f7cbe9c1d --- /dev/null +++ b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/env.d.ts @@ -0,0 +1 @@ +/// <reference types="astro/client-image" /> diff --git a/packages/integrations/netlify/test/hosted/hosted-astro-project/src/middleware.ts b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/middleware.ts new file mode 100644 index 000000000..1112a3566 --- /dev/null +++ b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/middleware.ts @@ -0,0 +1,11 @@ +import https from 'node:https'; + +export const onRequest = (context, next) => { + console.info(context.netlify); + context.locals.middleware = context?.locals?.netlify?.context?.geo?.country?.code ?? null; + context.locals.runtime = 'Deno' in globalThis ? 'Deno' : 'Node'; + context.locals.title = 'Middleware'; + context.locals.nodePrefixedImportExists = !!https; + + return next(); +}; diff --git a/packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/country.astro b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/country.astro new file mode 100644 index 000000000..cad7116d6 --- /dev/null +++ b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/country.astro @@ -0,0 +1,7 @@ +--- +const country = Astro.locals.middleware; +--- + +<h1>{country}</h1> +<h3>{country ? 'has context' : 'no context'}</h3> +<h2>{Astro.locals.runtime}</h2> diff --git a/packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/index.astro b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/index.astro new file mode 100644 index 000000000..7d2cfcdc3 --- /dev/null +++ b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/index.astro @@ -0,0 +1,13 @@ +--- +import { Image } from 'astro:assets'; +import penguin from '../assets/penguin.png'; +--- + +<Image src={penguin} width={300} alt="" /> + +<Image + src="https://images.unsplash.com/photo-1567674867291-b2595ac53ab4" + width={300} + height={400} + alt="Astro" +/> diff --git a/packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/time.astro b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/time.astro new file mode 100644 index 000000000..873b5c720 --- /dev/null +++ b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/time.astro @@ -0,0 +1,5 @@ +--- +const currentTime = new Date().getTime(); +--- + +{currentTime} |