Skip to content

Commit 1cd284c

Browse files
authored
add persistence badge for aws services (#34)
1 parent 82875d8 commit 1cd284c

File tree

4 files changed

+159
-1
lines changed

4 files changed

+159
-1
lines changed

astro.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default defineConfig({
4040
favicon: '/images/favicons/favicon.ico',
4141
customCss: ['./src/styles/global.css'],
4242
components: {
43-
PageTitle: './src/components/PageTitleWithPricing.astro',
43+
PageTitle: './src/components/PageTitleWithBadges.astro',
4444
},
4545
head: [
4646
{
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
import Default from '@astrojs/starlight/components/PageTitle.astro';
3+
import PersistenceBadge from './PersistenceBadge.astro';
4+
5+
// Get the current page route
6+
const route = Astro.locals.starlightRoute;
7+
const isAwsServicePage = route.id.startsWith('aws/services/') && !route.id.includes('/index');
8+
const tags = route.entry?.data?.tags || [];
9+
10+
const pricingTags = tags.filter(tag =>
11+
['Free', 'Base', 'Ultimate'].includes(tag)
12+
);
13+
14+
const getAvailablePlans = (plans) => {
15+
if (plans.includes('Free')) {
16+
return ['Free', 'Base', 'Ultimate'];
17+
} else if (plans.includes('Base')) {
18+
return ['Base', 'Ultimate'];
19+
} else if (plans.includes('Ultimate')) {
20+
return ['Ultimate'];
21+
}
22+
return plans;
23+
};
24+
25+
const availablePlans = getAvailablePlans(pricingTags);
26+
---
27+
28+
<Default />
29+
30+
{isAwsServicePage && availablePlans.length > 0 && (
31+
<div class="pricing-badges">
32+
{availablePlans.map(plan => (
33+
<span class={`pricing-badge pricing-badge-${plan.toLowerCase()}`}>
34+
{plan}
35+
</span>
36+
))}
37+
</div>
38+
)}
39+
40+
<PersistenceBadge />
41+
42+
<style>
43+
.pricing-badges {
44+
margin-top: 0.5rem;
45+
margin-bottom: 1.5rem;
46+
display: flex;
47+
gap: 0.5rem;
48+
flex-wrap: wrap;
49+
}
50+
51+
.pricing-badge {
52+
display: inline-flex;
53+
align-items: center;
54+
padding: 0.25rem 0.75rem;
55+
border-radius: 1rem;
56+
font-size: 0.875rem;
57+
font-weight: 600;
58+
text-transform: uppercase;
59+
letter-spacing: 0.025em;
60+
}
61+
62+
.pricing-badge-free {
63+
background-color: #dcfce7;
64+
color: #166534;
65+
border: 1px solid #bbf7d0;
66+
}
67+
68+
.pricing-badge-base {
69+
background-color: #dbeafe;
70+
color: #1e40af;
71+
border: 1px solid #93c5fd;
72+
}
73+
74+
.pricing-badge-ultimate {
75+
background-color: #fef3c7;
76+
color: #92400e;
77+
border: 1px solid #fcd34d;
78+
}
79+
</style>
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
// Get the current page route
3+
const route = Astro.locals.starlightRoute;
4+
const isAwsServicePage = route.id.startsWith('aws/services/') && !route.id.includes('/index');
5+
const persistence = route.entry?.data?.persistence || null;
6+
7+
// Determine persistence status and display text
8+
const getPersistenceInfo = (persistenceValue) => {
9+
if (!persistenceValue) {
10+
return { status: 'not-supported', text: 'Not Supported' };
11+
} else if (persistenceValue === 'supported') {
12+
return { status: 'supported', text: 'Supported' };
13+
} else if (persistenceValue === 'supported with limitations') {
14+
return { status: 'limited', text: 'Limited Support' };
15+
} else {
16+
return { status: 'not-supported', text: 'Not Supported' };
17+
}
18+
};
19+
20+
const persistenceInfo = getPersistenceInfo(persistence);
21+
---
22+
23+
{isAwsServicePage && (
24+
<div class="persistence-badges">
25+
<span class="badge-label">Persistence:</span>
26+
<span class={`persistence-badge persistence-badge-${persistenceInfo.status}`}>
27+
{persistenceInfo.text}
28+
</span>
29+
</div>
30+
)}
31+
32+
<style>
33+
.persistence-badges {
34+
margin-top: 0.5rem;
35+
margin-bottom: 1.5rem;
36+
display: flex;
37+
align-items: center;
38+
gap: 0.5rem;
39+
flex-wrap: wrap;
40+
}
41+
42+
.badge-label {
43+
font-size: 0.875rem;
44+
font-weight: 600;
45+
color: #6b7280;
46+
margin-right: 0.25rem;
47+
}
48+
49+
.persistence-badge {
50+
display: inline-flex;
51+
align-items: center;
52+
padding: 0.25rem 0.75rem;
53+
border-radius: 1rem;
54+
font-size: 0.875rem;
55+
font-weight: 600;
56+
text-transform: uppercase;
57+
letter-spacing: 0.025em;
58+
}
59+
60+
/* Persistence badge styles */
61+
.persistence-badge-supported {
62+
background-color: #d1fae5;
63+
color: #065f46;
64+
border: 1px solid #a7f3d0;
65+
}
66+
67+
.persistence-badge-limited {
68+
background-color: #fef3c7;
69+
color: #92400e;
70+
border: 1px solid #fcd34d;
71+
}
72+
73+
.persistence-badge-not-supported {
74+
background-color: #fee2e2;
75+
color: #991b1b;
76+
border: 1px solid #fecaca;
77+
}
78+
</style>

src/content.config.ts

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

0 commit comments

Comments
 (0)