Skip to content

Commit 82875d8

Browse files
authored
add pricing bagdes to the service pages (#33)
* get the mvp ready * design changes * apply inheritance logic
1 parent 850334d commit 82875d8

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

astro.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ export default defineConfig({
3939
title: 'Docs',
4040
favicon: '/images/favicons/favicon.ico',
4141
customCss: ['./src/styles/global.css'],
42+
components: {
43+
PageTitle: './src/components/PageTitleWithPricing.astro',
44+
},
4245
head: [
4346
{
4447
tag: 'script',
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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>

src/content.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const collections = {
1212
deployment: z.array(z.string()).optional(),
1313
pro: z.boolean().optional(),
1414
leadimage: z.string().optional(),
15+
tags: z.array(z.string()).optional(),
1516
}),
1617
}),
1718
}),

0 commit comments

Comments
 (0)