mirror of
https://github.com/cloudflare/cloudflare-docs.git
synced 2026-01-11 20:06:58 +00:00
* [Docs Site] Adopt eslint * Demonstrate a fixable suggestion, add VSCode plugin and package.json script * Fix slice in ModelCatalog * Remove test error in AnchorHeading * recreate package-lock.json * update new .jsx components to .tsx * amend deps, fix react types, organise ec plugins * another attempt at fixing platform-specific deps * fix FieldCatalog filters, remove test block from code.mdx * use opacity instead of brightness for ruleid * fix lockfile * amend ruleid opacity styling * test onetrust * enable prefer const rule, remove onetrust test * add save-dev
44 lines
1,018 B
Text
44 lines
1,018 B
Text
---
|
|
import { z } from "astro:schema";
|
|
import { indexPlans } from "~/util/plans";
|
|
import { zodEnumFromObjKeys } from "~/util/helpers";
|
|
|
|
const mappings = {
|
|
all: "Available on all plans",
|
|
paid: "Available on Paid plans",
|
|
pro: "Pro and above",
|
|
business: "Business and above",
|
|
enterprise: "Enterprise-only",
|
|
"add-on": "Add-on feature",
|
|
"ent-add-on": "Enterprise-only paid add-on",
|
|
"workers-all": "Available on Free and Paid plans",
|
|
"workers-paid": "Available on Workers Paid plan",
|
|
} as const satisfies Record<string, string>;
|
|
|
|
type Props = z.infer<typeof props>;
|
|
|
|
const props = z
|
|
.object({
|
|
type: zodEnumFromObjKeys(mappings),
|
|
})
|
|
.or(
|
|
z.object({
|
|
id: z.string(),
|
|
}),
|
|
);
|
|
|
|
// @ts-expect-error plans are not typed
|
|
const { id, type } = props.parse(Astro.props);
|
|
|
|
let availability;
|
|
if (type) {
|
|
// @ts-expect-error plans are not typed
|
|
availability = mappings[type];
|
|
} else {
|
|
availability = await indexPlans(id);
|
|
}
|
|
---
|
|
|
|
<div class="font-semibold text-blue-700 dark:text-indigo-300">
|
|
{availability}
|
|
</div>
|