diff options
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/Card.astro | 37 | ||||
| -rw-r--r-- | src/components/ContextAlert.astro | 28 | ||||
| -rw-r--r-- | src/components/EdgeFunctionExplainer.astro | 24 | ||||
| -rw-r--r-- | src/components/Footer.astro | 11 | ||||
| -rw-r--r-- | src/components/Header.astro | 30 |
5 files changed, 87 insertions, 43 deletions
diff --git a/src/components/Card.astro b/src/components/Card.astro index cbe0b0a..da68297 100644 --- a/src/components/Card.astro +++ b/src/components/Card.astro @@ -1,29 +1,26 @@ --- interface Props { - title?: string; - text?: string; - linkText?: string; - href?: string; + title?: string; + text?: string; + linkText?: string; + href?: string; } const { title, text, linkText, href } = Astro.props; --- <div class="bg-white text-neutral-600 card"> - <div class="card-body"> - {title && <h3 class="text-neutral-900 card-title">{title}</h3>} - {text && <p>{text}</p>} - { - linkText && href && ( - <div class="card-actions"> - <a - href={href} - class="transition link text-neutral-900 hover:opacity-80" - > - {linkText} - </a> - </div> - ) - } - </div> + <div class="card-body"> + {title && <h3 class="text-neutral-900 card-title">{title}</h3>} + {text && <p>{text}</p>} + { + linkText && href && ( + <div class="card-actions"> + <a href={href} class="link text-neutral-900"> + {linkText} + </a> + </div> + ) + } + </div> </div> diff --git a/src/components/ContextAlert.astro b/src/components/ContextAlert.astro new file mode 100644 index 0000000..ed54565 --- /dev/null +++ b/src/components/ContextAlert.astro @@ -0,0 +1,28 @@ +--- +import Alert from './Alert.astro'; +import Markdown from './Markdown.astro'; +import { getNetlifyContext } from '../utils'; + +const noNetlifyContextAlert = ` +For full functionality, either run this site locally via \`netlify dev\` +([see docs](https://docs.netlify.com/cli/local-development/")) or deploy it to Netlify. +`; + +const { addedChecksFunction, class: className } = Astro.props; +const ctx = getNetlifyContext(); + +let markdownText = null; +if (!ctx) { + markdownText = noNetlifyContextAlert; +} else if (addedChecksFunction) { + markdownText = addedChecksFunction(ctx); +} +--- + +{ + markdownText && ( + <Alert class={className}> + <Markdown content={markdownText} /> + </Alert> + ) +} diff --git a/src/components/EdgeFunctionExplainer.astro b/src/components/EdgeFunctionExplainer.astro new file mode 100644 index 0000000..fb6e6ae --- /dev/null +++ b/src/components/EdgeFunctionExplainer.astro @@ -0,0 +1,24 @@ +--- +import Markdown from './Markdown.astro'; + +const explainer = ` +This page is using a Netlify Edge Function (\`netlify/edge-functions/rewrite.js\`) to rewrite the URL based on visitor geography. + +~~~js +const rewrite = async (request, context) => { + const path = context.geo?.country?.code === 'AU' ? '/edge/australia' : '/edge/not-australia'; + return new URL(path, request.url); +}; + +export const config = { + path: '/edge' +}; + +export default rewrite; +~~~ + +[See more examples](https://edge-functions-examples.netlify.app) +`; +--- + +<Markdown content={explainer} /> diff --git a/src/components/Footer.astro b/src/components/Footer.astro index dd98602..9eb5917 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -3,12 +3,7 @@ --- <footer class="pt-16 pb-12 sm:pt-24 sm:pb-16"> - <p class="text-sm"> - <a - href="https://docs.netlify.com/frameworks/astro/" - class="underline transition decoration-dashed text-primary underline-offset-8 hover:opacity-80" - > - Astro.js on Netlify - </a> - </p> + <p class="text-sm"> + <a href="https://docs.netlify.com/frameworks/astro/" class="decoration-dashed text-primary underline-offset-8"> Astro.js on Netlify </a> + </p> </footer> diff --git a/src/components/Header.astro b/src/components/Header.astro index 724150e..e06ea28 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -12,18 +12,18 @@ const navItems = [ <a href="/"> <img src="/netlify-logo.svg" alt="Netlify logo" /> </a> - {!!navItems?.length && ( - <ul class="flex flex-wrap gap-x-4 gap-y-1"> - {navItems.map((item) => ( - <li> - <a - href={item.href} - class="inline-block px-1.5 py-1 transition hover:opacity-80 sm:px-3 sm:py-2" - > - {item.linkText} - </a> - </li> - ))} - </ul> - )} -</nav>
\ No newline at end of file + { + !!navItems?.length && ( + <ul class="flex flex-wrap gap-x-4 gap-y-1"> + {navItems.map((item) => ( + <li> + <a href={item.href} class="inline-block px-1.5 py-1 sm:px-3 sm:py-2"> + {item.linkText} + </a> + </li> + ))} + </ul> + ) + } +</nav> + |
