Skip to content

Commit 72b7b62

Browse files
committed
add contributing page
1 parent 4968d56 commit 72b7b62

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
title: Banners
3+
noindex: true
4+
sidebar_order: 80
5+
---
6+
7+
You can add arbitrary banners to the top of a page by adding adding an entry to the `BANNERS` array on
8+
the `banner/index.tsx` file. The `BANNERS` array is an array of objects with the following properties:
9+
10+
```typescript {filename:banner/index.tsx}
11+
type BannerType = {
12+
/** This is an array of strings or RegExps to feed into new RegExp() */
13+
appearsOn: (string | RegExp)[];
14+
/** The label for the call to action button */
15+
linkText: string;
16+
/** The destination url of the call to action button */
17+
linkURL: string;
18+
/** The main text of the banner */
19+
text: string;
20+
/** Optional ISO Date string that will hide the banner after this date without the need for a rebuild */
21+
expiresOn?: string;
22+
};
23+
```
24+
25+
You can add as many banners as you like. If you need to disable all banners, simply delete them from the array.
26+
27+
Each banner is evaluated in order, and the first one that matches will be shown.
28+
29+
Examples:
30+
31+
```typescript {filename:banner/index.tsx}
32+
// ...
33+
// appearsOn = []; // This is disabled
34+
// appearsOn = ['^/$']; // This is enabled on the home page
35+
// appearsOn = ['^/welcome/']; // This is enabled on the "/welcome" page
36+
// ...
37+
38+
const BANNERS = [
39+
// This one will take precedence over the last banner in the array
40+
// (which matches all /platforms pages), because it matches first.
41+
{
42+
appearsOn: ['^/platforms/javascript/guides/astro/'],
43+
text: 'This banner appears on the Astro guide',
44+
linkURL: 'https://sentry.io/thought-leadership',
45+
linkText: 'Get webinarly',
46+
},
47+
48+
// This one will match the /welcome page and all /for pages
49+
{
50+
appearsOn: ['^/$', '^/platforms/'],
51+
text: 'This banner appears on the home page and all /platforms pages',
52+
linkURL: 'https://sentry.io/thought-leadership',
53+
linkText: 'Get webinarly',
54+
},
55+
];
56+
57+
```
58+
59+
Optionally, you can add an `expiresOn` property to a banner to hide it after a certain date without requiring a rebuild or manual removeal.
60+
the ISO Date string should be in the format `YYYY-MM-DDTHH:MM:SSZ` to be parsed correctly and account for timezones.
61+
62+
```typescript {filename:banner/index.tsx}
63+
const BANNERS = [
64+
{
65+
appearsOn: ['^/$'],
66+
text: 'This home page banner will disappear after 2024-12-06',
67+
linkURL: 'https://sentry.io/party',
68+
linkText: 'RSVP',
69+
expiresOn: '2024-12-06T00:00:00Z',
70+
},
71+
];
72+
```

src/components/banner/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ const BANNERS: BannerType[] = [
7979
linkURL: 'https://sentry.io/thought-leadership',
8080
linkText: 'Get webinarly',
8181
},
82+
83+
/// ⚠️ KEEP THIS LAST BANNER ACTIVE FOR DOCUMENTATION
84+
// check it out on `/contributing/pages/banners/`
85+
{
86+
appearsOn: ['^/contributing/pages/banners/'],
87+
text: 'Edit this banner on `/src/components/banner/index.tsx`',
88+
linkURL: 'https://docs.sentry.io/contributing/pages/banners/',
89+
linkText: 'CTA',
90+
},
8291
];
8392

8493
const LOCALSTORAGE_NAMESPACE = 'banner-manifest';

0 commit comments

Comments
 (0)