Skip to content

Commit b4048ec

Browse files
committed
apply inheritance logic
1 parent d0672fd commit b4048ec

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/components/PageTitleWithPricing.astro

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,31 @@ const route = Astro.locals.starlightRoute;
66
const isAwsServicePage = route.id.startsWith('aws/services/') && !route.id.includes('/index');
77
const tags = route.entry?.data?.tags || [];
88
9-
// Find pricing tags
109
const pricingTags = tags.filter(tag =>
1110
['Free', 'Base', 'Ultimate'].includes(tag)
1211
);
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);
1325
---
1426

1527
<Default />
1628

17-
{isAwsServicePage && pricingTags.length > 0 && (
29+
{isAwsServicePage && availablePlans.length > 0 && (
1830
<div class="pricing-badges">
19-
{pricingTags.map(tag => (
20-
<span class={`pricing-badge pricing-badge-${tag.toLowerCase()}`}>
21-
{tag}
31+
{availablePlans.map(plan => (
32+
<span class={`pricing-badge pricing-badge-${plan.toLowerCase()}`}>
33+
{plan}
2234
</span>
2335
))}
2436
</div>
@@ -61,4 +73,4 @@ const pricingTags = tags.filter(tag =>
6173
color: #92400e;
6274
border: 1px solid #fcd34d;
6375
}
64-
</style>
76+
</style>

0 commit comments

Comments
 (0)