diff options
| author | Tomas Bankauskas <tbdizainas@gmail.com> | 2024-04-09 13:48:36 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-09 13:48:36 +0300 |
| commit | 5396de306695226c939384598410761297739fef (patch) | |
| tree | 7922668f00823e21ab7ab799fa4cf5c811bf0613 /src/components/EdgeFunctionExplainer.astro | |
| parent | 3bebbf00e6f4d33bfacbf38eef73a9ad7f0d9d58 (diff) | |
| parent | be4de751ad432f8230d83e1d6cbb3e56d608cd58 (diff) | |
Merge pull request #5 from netlify-templates/edge-page
Added edge page
Diffstat (limited to 'src/components/EdgeFunctionExplainer.astro')
| -rw-r--r-- | src/components/EdgeFunctionExplainer.astro | 24 |
1 files changed, 24 insertions, 0 deletions
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} /> |
