diff --git a/astro.config.mjs b/astro.config.mjs index 8312dae8..96d6697f 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -40,7 +40,7 @@ export default defineConfig({ favicon: '/images/favicons/favicon.ico', customCss: ['./src/styles/global.css'], components: { - PageTitle: './src/components/PageTitleWithPricing.astro', + PageTitle: './src/components/PageTitleWithBadges.astro', }, head: [ { diff --git a/src/components/PageTitleWithBadges.astro b/src/components/PageTitleWithBadges.astro new file mode 100644 index 00000000..7ab6f310 --- /dev/null +++ b/src/components/PageTitleWithBadges.astro @@ -0,0 +1,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); +--- + + + +{isAwsServicePage && availablePlans.length > 0 && ( +
+ {availablePlans.map(plan => ( + + {plan} + + ))} +
+)} + + + + \ No newline at end of file diff --git a/src/components/PersistenceBadge.astro b/src/components/PersistenceBadge.astro new file mode 100644 index 00000000..902e93a9 --- /dev/null +++ b/src/components/PersistenceBadge.astro @@ -0,0 +1,78 @@ +--- +// Get the current page route +const route = Astro.locals.starlightRoute; +const isAwsServicePage = route.id.startsWith('aws/services/') && !route.id.includes('/index'); +const persistence = route.entry?.data?.persistence || null; + +// Determine persistence status and display text +const getPersistenceInfo = (persistenceValue) => { + if (!persistenceValue) { + return { status: 'not-supported', text: 'Not Supported' }; + } else if (persistenceValue === 'supported') { + return { status: 'supported', text: 'Supported' }; + } else if (persistenceValue === 'supported with limitations') { + return { status: 'limited', text: 'Limited Support' }; + } else { + return { status: 'not-supported', text: 'Not Supported' }; + } +}; + +const persistenceInfo = getPersistenceInfo(persistence); +--- + +{isAwsServicePage && ( +
+ Persistence: + + {persistenceInfo.text} + +
+)} + + \ No newline at end of file diff --git a/src/content.config.ts b/src/content.config.ts index e7ef5a39..01260afd 100644 --- a/src/content.config.ts +++ b/src/content.config.ts @@ -13,6 +13,7 @@ export const collections = { pro: z.boolean().optional(), leadimage: z.string().optional(), tags: z.array(z.string()).optional(), + persistence: z.string().optional(), }), }), }),