From be4de751ad432f8230d83e1d6cbb3e56d608cd58 Mon Sep 17 00:00:00 2001 From: TomasBankauskas Date: Tue, 9 Apr 2024 13:44:24 +0300 Subject: updates --- src/pages/_assets/corgi.jpg | Bin 587671 -> 0 bytes src/pages/blobs.astro | 6 +---- src/pages/edge/australia/index.astro | 9 +++++++ src/pages/edge/index.astro | 21 +++++++++++++++ src/pages/edge/not-australia/index.astro | 9 +++++++ src/pages/image-cdn.astro | 44 ++++++++++++++++++++----------- src/pages/index.astro | 23 ++++++---------- 7 files changed, 77 insertions(+), 35 deletions(-) delete mode 100644 src/pages/_assets/corgi.jpg create mode 100644 src/pages/edge/australia/index.astro create mode 100644 src/pages/edge/index.astro create mode 100644 src/pages/edge/not-australia/index.astro (limited to 'src/pages') diff --git a/src/pages/_assets/corgi.jpg b/src/pages/_assets/corgi.jpg deleted file mode 100644 index 402232f..0000000 Binary files a/src/pages/_assets/corgi.jpg and /dev/null differ diff --git a/src/pages/blobs.astro b/src/pages/blobs.astro index 61da040..2884c4a 100644 --- a/src/pages/blobs.astro +++ b/src/pages/blobs.astro @@ -3,10 +3,6 @@ import Layout from "../layouts/Layout.astro"; --- -
-
-

Blobs x Blobs

+

Blobs x Blobs

Get started with Astro.js and Netlify in seconds.

-
-
diff --git a/src/pages/edge/australia/index.astro b/src/pages/edge/australia/index.astro new file mode 100644 index 0000000..59965dd --- /dev/null +++ b/src/pages/edge/australia/index.astro @@ -0,0 +1,9 @@ +--- +import Layout from "../../../layouts/Layout.astro"; +import EdgeFunctionExplainer from "../../../components/EdgeFunctionExplainer.astro"; +--- + + +

You are in Australia!

+ +
diff --git a/src/pages/edge/index.astro b/src/pages/edge/index.astro new file mode 100644 index 0000000..f49f3a9 --- /dev/null +++ b/src/pages/edge/index.astro @@ -0,0 +1,21 @@ +--- +import Layout from '../../layouts/Layout.astro'; +import Markdown from '../../components/Markdown.astro'; + +const explainer = ` +# You've reached the fallback page. + +This page is using a [Netlify Edge Function](https://docs.netlify.com/edge-functions/overview/) to rewrite the URL based on visitor geography. + +For it to be invoked, please either run this site locally with \`netlify dev\` or deploy it to Netlify. + +Edge Functions are framework-agnostic, but are also used behind the scenes to run Next.js Middleware on Netlify. +There are advatanges to using Edge Functions directly, such as the ability to access & transform the response body. + +[See more examples](https://edge-functions-examples.netlify.app) +`; +--- + + + + diff --git a/src/pages/edge/not-australia/index.astro b/src/pages/edge/not-australia/index.astro new file mode 100644 index 0000000..74c2577 --- /dev/null +++ b/src/pages/edge/not-australia/index.astro @@ -0,0 +1,9 @@ +--- +import Layout from '../../../layouts/Layout.astro'; +import EdgeFunctionExplainer from '../../../components/EdgeFunctionExplainer.astro'; +--- + + +

You're not in Australia!

+ +
diff --git a/src/pages/image-cdn.astro b/src/pages/image-cdn.astro index aa1b4e6..8847536 100644 --- a/src/pages/image-cdn.astro +++ b/src/pages/image-cdn.astro @@ -1,12 +1,20 @@ --- import { Image } from 'astro:assets'; +import ContextAlert from '../components/ContextAlert.astro'; import Layout from '../layouts/Layout.astro'; import Markdown from '../components/Markdown.astro'; -import corgi from './_assets/corgi.jpg'; +import corgi from '../assets/corgi.jpg'; +import { getNetlifyContext } from '../utils'; -const sampleImageSrc = '/images/corgi.jpg'; +const sampleImage = '/images/corgi.jpg'; + +const ctx = getNetlifyContext(); +const forceWebP = ctx === 'dev'; +const sampleImageNetlify = `/.netlify/images?url=${sampleImage}${forceWebP ? '&fm=webp' : ''}`; const astroImageSnippet = ` +## Using built-in Astro <Image /> component + When running on Netlify, \`next/image\` is automatically set-up to use Netlify Image CDN for optimized images. ~~~jsx @@ -18,6 +26,8 @@ import Image from 'next/image'; `; const originalVsCdnSnippet = ` +## Original vs. optimized image: can you tell the difference? + In the code below, a regular \`\` tag is used in both cases for a framework-agnostic example. Other than using \`next/image\` or rolling your own \`\` tags, you can also use the excellent [unpic-img](https://unpic.pics/). @@ -33,37 +43,41 @@ Other than using \`next/image\` or rolling your own \`\` tags, you can also /> ~~~ `; + +const devModeWarning = ` +In local development, optimization is performed locally without automatic format +detection, so format is set to WebP. +`; --- -
-
-

Image CDN

+
+
+ { + return ctx === "dev" ? devModeWarning : null; + } + } /> +

Image CDN

-

Using built-in Astro <Image /> component

Corgi
- Credit: photo by Alvan Nee on - - Unsplash - + Credit: photo by Alvan Nee on + Unsplash
-

Original vs. optimized image: can you tell the difference?

- Corgi + Corgi
@@ -71,7 +85,7 @@ Other than using \`next/image\` or rolling your own \`\` tags, you can also
- Corgi + Corgi
diff --git a/src/pages/index.astro b/src/pages/index.astro index 2a3c105..8955471 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,20 +1,13 @@ --- -import Layout from "../layouts/Layout.astro"; -import Card from "../components/Card.astro"; +import Layout from '../layouts/Layout.astro'; +import Card from '../components/Card.astro'; --- -
-
-

Netlify Platform Starter - Astro.js

-

Get started with Astro.js and Netlify in seconds.

- - Read the Docs - - -
-
+

Netlify Platform Starter - Astro.js

+

Get started with Astro.js and Netlify in seconds.

+

+ Read the Docs +

+
-- cgit v1.2.3