aboutsummaryrefslogtreecommitdiff
path: root/packages/integrations/netlify/test/hosted/hosted-astro-project
diff options
context:
space:
mode:
Diffstat (limited to 'packages/integrations/netlify/test/hosted/hosted-astro-project')
-rw-r--r--packages/integrations/netlify/test/hosted/hosted-astro-project/astro.config.mjs19
-rw-r--r--packages/integrations/netlify/test/hosted/hosted-astro-project/netlify.toml3
-rw-r--r--packages/integrations/netlify/test/hosted/hosted-astro-project/package.json12
-rw-r--r--packages/integrations/netlify/test/hosted/hosted-astro-project/src/assets/penguin.pngbin0 -> 7295878 bytes
-rw-r--r--packages/integrations/netlify/test/hosted/hosted-astro-project/src/env.d.ts1
-rw-r--r--packages/integrations/netlify/test/hosted/hosted-astro-project/src/middleware.ts11
-rw-r--r--packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/country.astro7
-rw-r--r--packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/index.astro13
-rw-r--r--packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/time.astro5
9 files changed, 71 insertions, 0 deletions
diff --git a/packages/integrations/netlify/test/hosted/hosted-astro-project/astro.config.mjs b/packages/integrations/netlify/test/hosted/hosted-astro-project/astro.config.mjs
new file mode 100644
index 000000000..94cc00f7b
--- /dev/null
+++ b/packages/integrations/netlify/test/hosted/hosted-astro-project/astro.config.mjs
@@ -0,0 +1,19 @@
+import netlify from '@astrojs/netlify';
+import { defineConfig } from 'astro/config';
+
+// https://astro.build/config
+export default defineConfig({
+ output: 'server',
+ adapter: netlify({
+ edgeMiddleware: true,
+ }),
+ image: {
+ remotePatterns: [
+ {
+ protocol: 'https',
+ hostname: 'images.unsplash.com',
+ pathname: '/photo-1567674867291-b2595ac53ab4',
+ },
+ ],
+ },
+});
diff --git a/packages/integrations/netlify/test/hosted/hosted-astro-project/netlify.toml b/packages/integrations/netlify/test/hosted/hosted-astro-project/netlify.toml
new file mode 100644
index 000000000..55c8404ee
--- /dev/null
+++ b/packages/integrations/netlify/test/hosted/hosted-astro-project/netlify.toml
@@ -0,0 +1,3 @@
+[build]
+command = "pnpm run --filter @test/netlify-hosted-astro-project... build"
+publish = "/packages/netlify/test/hosted/hosted-astro-project/dist"
diff --git a/packages/integrations/netlify/test/hosted/hosted-astro-project/package.json b/packages/integrations/netlify/test/hosted/hosted-astro-project/package.json
new file mode 100644
index 000000000..0624ca789
--- /dev/null
+++ b/packages/integrations/netlify/test/hosted/hosted-astro-project/package.json
@@ -0,0 +1,12 @@
+{
+ "name": "@test/netlify-hosted-astro-project",
+ "version": "0.0.0",
+ "private": true,
+ "scripts": {
+ "build": "astro build"
+ },
+ "dependencies": {
+ "@astrojs/netlify": "workspace:*",
+ "astro": "workspace:*"
+ }
+}
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
new file mode 100644
index 000000000..218acde5b
--- /dev/null
+++ b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/assets/penguin.png
Binary files differ
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}