summaryrefslogtreecommitdiff
path: root/src/components/ContextAlert.astro
diff options
context:
space:
mode:
authorTomas Bankauskas <tbdizainas@gmail.com>2024-04-09 13:48:36 +0300
committerGitHub <noreply@github.com>2024-04-09 13:48:36 +0300
commit5396de306695226c939384598410761297739fef (patch)
tree7922668f00823e21ab7ab799fa4cf5c811bf0613 /src/components/ContextAlert.astro
parent3bebbf00e6f4d33bfacbf38eef73a9ad7f0d9d58 (diff)
parentbe4de751ad432f8230d83e1d6cbb3e56d608cd58 (diff)
Merge pull request #5 from netlify-templates/edge-page
Added edge page
Diffstat (limited to 'src/components/ContextAlert.astro')
-rw-r--r--src/components/ContextAlert.astro28
1 files changed, 28 insertions, 0 deletions
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>
+ )
+}