summaryrefslogtreecommitdiff
path: root/src/components/ContextAlert.astro
blob: 61273c31cebf974703a8c2e88f87673105a8bcaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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>
    )
}