-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathPageTitleWithBadges.astro
More file actions
79 lines (67 loc) · 1.73 KB
/
PageTitleWithBadges.astro
File metadata and controls
79 lines (67 loc) · 1.73 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
---
import Default from '@astrojs/starlight/components/PageTitle.astro';
import PersistenceBadge from './PersistenceBadge.astro';
// Get the current page route
const route = Astro.locals.starlightRoute;
const isAwsServicePage = route.id.startsWith('aws/services/') && !route.id.includes('/index');
const tags = route.entry?.data?.tags || [];
const pricingTags = tags.filter(tag =>
['Free', 'Base', 'Ultimate'].includes(tag)
);
const getAvailablePlans = (plans) => {
if (plans.includes('Free')) {
return ['Free', 'Base', 'Ultimate'];
} else if (plans.includes('Base')) {
return ['Base', 'Ultimate'];
} else if (plans.includes('Ultimate')) {
return ['Ultimate'];
}
return plans;
};
const availablePlans = getAvailablePlans(pricingTags);
---
<Default />
{isAwsServicePage && availablePlans.length > 0 && (
<div class="pricing-badges">
{availablePlans.map(plan => (
<span class={`pricing-badge pricing-badge-${plan.toLowerCase()}`}>
{plan}
</span>
))}
</div>
)}
<PersistenceBadge />
<style>
.pricing-badges {
margin-top: 0.5rem;
margin-bottom: 1.5rem;
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
}
.pricing-badge {
display: inline-flex;
align-items: center;
padding: 0.25rem 0.75rem;
border-radius: 1rem;
font-size: 0.875rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.025em;
}
.pricing-badge-free {
background-color: #dcfce7;
color: #166534;
border: 1px solid #bbf7d0;
}
.pricing-badge-base {
background-color: #dbeafe;
color: #1e40af;
border: 1px solid #93c5fd;
}
.pricing-badge-ultimate {
background-color: #fef3c7;
color: #92400e;
border: 1px solid #fcd34d;
}
</style>