diff options
| author | TomasBankauskas <tbdizainas@gmail.com> | 2024-04-09 13:44:24 +0300 |
|---|---|---|
| committer | TomasBankauskas <tbdizainas@gmail.com> | 2024-04-09 13:44:24 +0300 |
| commit | be4de751ad432f8230d83e1d6cbb3e56d608cd58 (patch) | |
| tree | 7922668f00823e21ab7ab799fa4cf5c811bf0613 /src/pages | |
| parent | 3bebbf00e6f4d33bfacbf38eef73a9ad7f0d9d58 (diff) | |
updates
Diffstat (limited to 'src/pages')
| -rw-r--r-- | src/pages/_assets/corgi.jpg | bin | 587671 -> 0 bytes | |||
| -rw-r--r-- | src/pages/blobs.astro | 6 | ||||
| -rw-r--r-- | src/pages/edge/australia/index.astro | 9 | ||||
| -rw-r--r-- | src/pages/edge/index.astro | 21 | ||||
| -rw-r--r-- | src/pages/edge/not-australia/index.astro | 9 | ||||
| -rw-r--r-- | src/pages/image-cdn.astro | 44 | ||||
| -rw-r--r-- | src/pages/index.astro | 23 |
7 files changed, 77 insertions, 35 deletions
diff --git a/src/pages/_assets/corgi.jpg b/src/pages/_assets/corgi.jpg Binary files differdeleted file mode 100644 index 402232f..0000000 --- a/src/pages/_assets/corgi.jpg +++ /dev/null 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"; --- <Layout title="Blobs"> - <main class="flex flex-col gap-8 sm:gap-16"> - <section class="flex flex-col items-start gap-3 sm:gap-4"> - <h1>Blobs x Blobs</h1> + <h1 class="mb-8">Blobs x Blobs</h1> <p class="text-lg">Get started with Astro.js and Netlify in seconds.</p> - </section> - </main> </Layout> 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"; +--- + +<Layout title="In Australia"> + <h1 class="mb-8">You are in Australia!</h1> + <EdgeFunctionExplainer /> +</Layout> 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) +`; +--- + +<Layout title="Fallback"> + <Markdown content={explainer} /> +</Layout> 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'; +--- + +<Layout title="Not Autralia"> + <h1 class="mb-8">You're not in Australia!</h1> + <EdgeFunctionExplainer /> +</Layout> 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 \`<img>\` tag is used in both cases for a framework-agnostic example. Other than using \`next/image\` or rolling your own \`<img>\` 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 \`<img>\` tags, you can also /> ~~~ `; + +const devModeWarning = ` +In local development, optimization is performed locally without automatic format +detection, so format is set to WebP. +`; --- <Layout title="Image CDN"> - <div class="flex flex-col gap-8 sm:gap-16"> - <section> - <h1 class="mb-0">Image CDN</h1> + <div class="flex flex-col gap-12 sm:gap-16"> + <section class="space-y-8"> + <ContextAlert addedChecksFunction={ + (ctx) => { + return ctx === "dev" ? devModeWarning : null; + } + } /> + <h1>Image CDN</h1> </section> <section> - <h2 class="mb-6 text-2xl font-bold sm:text-3xl">Using built-in Astro <Image /> component</h2> <Markdown content={astroImageSnippet} class="mb-8" /> <figure> <Image src={corgi} alt="Corgi" class="border-2 border-white rounded-lg" /> <figcaption class="mt-2 text-sm italic"> - Credit: photo by <a href="https://unsplash.com/@alvannee?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Alvan Nee</a> on - <a - href="https://unsplash.com/photos/long-coated-white-and-brown-dog-lvFlpqEvuRM?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash" - > - Unsplash - </a> + Credit: photo by <a href="https://unsplash.com/@alvannee">Alvan Nee</a> on + <a href="https://unsplash.com/photos/long-coated-white-and-brown-dog-lvFlpqEvuRM"> Unsplash </a> </figcaption> </figure> </section> <section> - <h2 class="mb-6 text-2xl font-bold sm:text-3xl">Original vs. optimized image: can you tell the difference?</h2> <Markdown content={originalVsCdnSnippet} class="mb-8" /> <div class="diff aspect-[3/2] rounded-lg border-2 border-white"> <div class="diff-item-1"> <div> <div class="relative"> <span class="hidden absolute py-1.5 px-2.5 text-sm rounded-lg bg-neutral-900/70 top-2.5 right-2.5"></span> - <img src={`/.netlify/images?url=${sampleImageSrc}`} alt="Corgi" /> + <img src={sampleImageNetlify} alt="Corgi" /> </div> </div> </div> @@ -71,7 +85,7 @@ Other than using \`next/image\` or rolling your own \`<img>\` tags, you can also <div> <div class="relative"> <span class="hidden absolute py-1.5 px-2.5 text-sm rounded-lg bg-neutral-900/70 top-2.5 left-2.5"></span> - <img src={sampleImageSrc} alt="Corgi" /> + <img src={sampleImage} alt="Corgi" /> </div> </div> </div> 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'; --- <Layout title="Welcome to Astro."> - <main class="flex flex-col gap-8 sm:gap-16"> - <section class="flex flex-col items-start gap-3 sm:gap-4"> - <h1 class="mb-0">Netlify Platform Starter - Astro.js</h1> - <p class="text-lg">Get started with Astro.js and Netlify in seconds.</p> - <a - href="https://docs.netlify.com/frameworks/astro/" - class="btn btn-lg btn-primary sm:btn-wide" - > - Read the Docs - </a> - <Card title="Random Title" text="Long random text about Astro.js. Get started with Astro.js and Netlify in seconds." /> - </section> - </main> + <h1 class="mb-8">Netlify Platform Starter - Astro.js</h1> + <p class="mb-6 text-lg">Get started with Astro.js and Netlify in seconds.</p> + <p class="mb-8"> + <a href="https://docs.netlify.com/frameworks/astro/" class="btn btn-lg btn-primary sm:btn-wide">Read the Docs</a> + </p> + <Card title="Random Title" text="Long random text about Astro.js. Get started with Astro.js and Netlify in seconds." /> </Layout> |
