|
| 1 | +--- |
| 2 | +import Default from '@astrojs/starlight/components/PageTitle.astro'; |
| 3 | +
|
| 4 | +// Get the current page route |
| 5 | +const route = Astro.locals.starlightRoute; |
| 6 | +const isAwsServicePage = route.id.startsWith('aws/services/') && !route.id.includes('/index'); |
| 7 | +const tags = route.entry?.data?.tags || []; |
| 8 | +
|
| 9 | +const pricingTags = tags.filter(tag => |
| 10 | + ['Free', 'Base', 'Ultimate'].includes(tag) |
| 11 | +); |
| 12 | +
|
| 13 | +const getAvailablePlans = (plans) => { |
| 14 | + if (plans.includes('Free')) { |
| 15 | + return ['Free', 'Base', 'Ultimate']; |
| 16 | + } else if (plans.includes('Base')) { |
| 17 | + return ['Base', 'Ultimate']; |
| 18 | + } else if (plans.includes('Ultimate')) { |
| 19 | + return ['Ultimate']; |
| 20 | + } |
| 21 | + return plans; |
| 22 | +}; |
| 23 | +
|
| 24 | +const availablePlans = getAvailablePlans(pricingTags); |
| 25 | +--- |
| 26 | + |
| 27 | +<Default /> |
| 28 | + |
| 29 | +{isAwsServicePage && availablePlans.length > 0 && ( |
| 30 | + <div class="pricing-badges"> |
| 31 | + {availablePlans.map(plan => ( |
| 32 | + <span class={`pricing-badge pricing-badge-${plan.toLowerCase()}`}> |
| 33 | + {plan} |
| 34 | + </span> |
| 35 | + ))} |
| 36 | + </div> |
| 37 | +)} |
| 38 | + |
| 39 | +<style> |
| 40 | + .pricing-badges { |
| 41 | + margin-top: 0.5rem; |
| 42 | + margin-bottom: 1.5rem; |
| 43 | + display: flex; |
| 44 | + gap: 0.5rem; |
| 45 | + flex-wrap: wrap; |
| 46 | + } |
| 47 | + |
| 48 | + .pricing-badge { |
| 49 | + display: inline-flex; |
| 50 | + align-items: center; |
| 51 | + padding: 0.25rem 0.75rem; |
| 52 | + border-radius: 1rem; |
| 53 | + font-size: 0.875rem; |
| 54 | + font-weight: 600; |
| 55 | + text-transform: uppercase; |
| 56 | + letter-spacing: 0.025em; |
| 57 | + } |
| 58 | + |
| 59 | + .pricing-badge-free { |
| 60 | + background-color: #dcfce7; |
| 61 | + color: #166534; |
| 62 | + border: 1px solid #bbf7d0; |
| 63 | + } |
| 64 | + |
| 65 | + .pricing-badge-base { |
| 66 | + background-color: #dbeafe; |
| 67 | + color: #1e40af; |
| 68 | + border: 1px solid #93c5fd; |
| 69 | + } |
| 70 | + |
| 71 | + .pricing-badge-ultimate { |
| 72 | + background-color: #fef3c7; |
| 73 | + color: #92400e; |
| 74 | + border: 1px solid #fcd34d; |
| 75 | + } |
| 76 | +</style> |
0 commit comments