examples: Update Astro template. (#11687)

This commit is contained in:
Lee Robinson
2024-06-04 13:28:11 -05:00
committed by GitHub
parent 7457767a77
commit 58d9789e60
7 changed files with 23 additions and 34 deletions

View File

@@ -0,0 +1,5 @@
---
"examples": patch
---
examples: Update Astro template.

View File

@@ -1,3 +1,6 @@
# astro
.astro
# build output # build output
dist/ dist/
.output/ .output/
@@ -11,7 +14,6 @@ yarn-debug.log*
yarn-error.log* yarn-error.log*
pnpm-debug.log* pnpm-debug.log*
# environment variables # environment variables
.env .env
.env.production .env.production

View File

@@ -3,10 +3,9 @@
This directory is a brief example of an [Astro](https://astro.build/) site that can be deployed to Vercel with zero configuration. This demo showcases: This directory is a brief example of an [Astro](https://astro.build/) site that can be deployed to Vercel with zero configuration. This demo showcases:
- `/` - A static page (pre-rendered) - `/` - A static page (pre-rendered)
- `/ssr` - A page that uses server-side rendering (through [Vercel Edge Functions](https://vercel.com/docs/functions/edge-functions)) - `/ssr` - A page that uses server-side rendering (through [Vercel Functions](https://vercel.com/docs/functions))
- `/ssr-with-swr-caching` - Similar to the previous page, but also caches the response on the [Vercel Edge Network](https://vercel.com/docs/edge-network/overview) using `cache-control` headers - `/ssr-with-swr-caching` - Similar to the previous page, but also caches the response on the [Vercel Edge Network](https://vercel.com/docs/edge-network/overview) using `cache-control` headers
- `/image` - Astro [Asset](https://docs.astro.build/en/guides/assets/) using Vercel [Image Optimization](https://vercel.com/docs/image-optimization) - `/image` - Astro [Asset](https://docs.astro.build/en/guides/images/) using Vercel [Image Optimization](https://vercel.com/docs/image-optimization)
- `/edge.json` - An Astro API Endpoint that returns JSON data using [Vercel Edge Functions](https://vercel.com/docs/functions/edge-functions)
Learn more about [Astro on Vercel](https://vercel.com/docs/frameworks/astro). Learn more about [Astro on Vercel](https://vercel.com/docs/frameworks/astro).

View File

@@ -1,17 +0,0 @@
import { defineConfig } from 'astro/config';
// Use Vercel Edge Functions (Recommended)
import vercel from '@astrojs/vercel/edge';
// Can also use Serverless Functions
// import vercel from '@astrojs/vercel/serverless';
// Or a completely static build
// import vercel from '@astrojs/vercel/static';
export default defineConfig({
output: 'server',
experimental: {
assets: true
},
adapter: vercel({
imageService: true,
}),
});

View File

@@ -0,0 +1,9 @@
import { defineConfig } from 'astro/config';
import vercelServerless from '@astrojs/vercel/serverless';
export default defineConfig({
output: 'server',
adapter: vercelServerless({
imageService: true,
}),
});

View File

@@ -8,9 +8,9 @@
"astro": "astro" "astro": "astro"
}, },
"dependencies": { "dependencies": {
"@astrojs/vercel": "3.8.2", "@astrojs/vercel": "7.6.0",
"astro": "^2.10.14", "astro": "^4.9.2",
"react": "18.2.0", "react": "18.3.1",
"web-vitals": "^3.3.1" "web-vitals": "^4.0.1"
} }
} }

View File

@@ -1,9 +0,0 @@
export async function get() {
return new Response(JSON.stringify({ time: new Date() }), {
status: 200,
headers: {
'Content-Type': 'application/json',
'Cache-Control': 's-maxage=10, stale-while-revalidate',
},
});
}