Skip to content

Commit

Permalink
[Astro] Public stats component (#16803)
Browse files Browse the repository at this point in the history
* [Astro] Public stats component

* Update slightly

* Add style guide page
  • Loading branch information
kodster28 authored Sep 17, 2024
1 parent 9355229 commit 3ea1943
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 58 deletions.
23 changes: 23 additions & 0 deletions src/components/PublicStats.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
import { z } from "astro:content";
import { zodEnumFromObjKeys } from "~/util/helpers";
type Props = z.infer<typeof props>;
const mappings = {
data_center_cities: "over 330 cities",
total_bandwidth: "over 296 Tbps network capacity",
network_peers: "over 12,500 network peers",
} as const satisfies Record<string, string>;
const props = z.object({
id: zodEnumFromObjKeys(mappings),
});
// @ts-ignore
const { id } = props.parse(Astro.props);
let stat = mappings[id];
---

{stat}
115 changes: 58 additions & 57 deletions src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,64 +1,65 @@
// Starlight built-ins
export * from "@astrojs/starlight/components"
export { Icon as StarlightIcon } from "@astrojs/starlight/components"
export * from "@astrojs/starlight/components";
export { Icon as StarlightIcon } from "@astrojs/starlight/components";
// Community packages
export { PackageManagers } from 'starlight-package-managers'
export { Icon as AstroIcon } from 'astro-icon/components'
export { PackageManagers } from "starlight-package-managers";
export { Icon as AstroIcon } from "astro-icon/components";
// Custom components
export { default as AnchorHeading } from "./AnchorHeading.astro"
export { default as AvailableNotifications } from "./AvailableNotifications.astro"
export { default as CompatibilityDates } from "./CompatibilityDates.astro"
export { default as Description } from "./Description.astro"
export { default as Details } from "./Details.astro"
export { default as DirectoryListing } from "./DirectoryListing.astro"
export { default as Example } from "./Example.astro"
export { default as ExternalResources } from "./ExternalResources.astro"
export { default as Feature } from "./Feature.astro"
export { default as FeatureTable } from "./FeatureTable.astro"
export { default as Glossary } from "./Glossary.astro"
export { default as GlossaryDefinition } from "./GlossaryDefinition.astro"
export { default as GlossaryTooltip } from "./GlossaryTooltip.astro"
export { default as HomepageHero } from "./HomepageHero.astro"
export { default as InlineBadge } from "./InlineBadge.astro"
export { default as LastReviewed } from "./LastReviewed.astro"
export { default as LearningPath } from "./LearningPath.astro"
export { default as LinkTitleCard } from "./LinkTitleCard.astro"
export { default as ListExamples } from "./ListExamples.astro"
export { default as ListTutorials } from "./ListTutorials.astro"
export { default as Markdown } from "./Markdown.astro"
export { default as NetworkMap } from "./NetworkMap.astro"
export { default as PagesBuildEnvironment } from "./PagesBuildEnvironment.astro"
export { default as PagesBuildEnvironmentLanguages } from "./PagesBuildEnvironmentLanguages.astro"
export { default as PagesBuildEnvironmentTools } from "./PagesBuildEnvironmentTools.astro"
export { default as PagesBuildPreset } from "./PagesBuildPreset.astro"
export { default as PagesBuildPresetsTable } from "./PagesBuildPresetsTable.astro"
export { default as PagesLanguageSupport } from "./PagesLanguageSupport.astro"
export { default as Plan } from "./Plan.astro"
export { default as PlanInfo } from "./PlanInfo.astro"
export { default as ProductChangelog } from "./ProductChangelog.astro"
export { default as ProductFeatures } from "./ProductFeatures.astro"
export { default as ProductsByTag } from "./ProductsByTag.astro"
export { default as RelatedProduct } from "./RelatedProduct.astro"
export { default as Render } from "./Render.astro"
export { default as ResourcesBySelector } from "./ResourcesBySelector.astro"
export { default as RuleID } from "./RuleID.astro"
export { default as SpotlightAuthorDetails } from "./SpotlightAuthorDetails.astro"
export { default as Stream } from "./Stream.astro"
export { default as ThreeCardGrid } from "./ThreeCardGrid.astro"
export { default as TroubleshootingList } from "./TroubleshootingList.astro"
export { default as TunnelCalculator } from "./TunnelCalculator.astro"
export { default as WorkersAIModels } from "./WorkersAIModels.astro"
export { default as WorkersArchitectureDiagram } from "./WorkersArchitectureDiagram.astro"
export { default as WorkersIsolateDiagram } from "./WorkersIsolateDiagram.astro"
export { default as WorkerStarter } from "./WorkerStarter.astro"
export { default as YouTube } from "./YouTube.astro"
export { default as AnchorHeading } from "./AnchorHeading.astro";
export { default as AvailableNotifications } from "./AvailableNotifications.astro";
export { default as CompatibilityDates } from "./CompatibilityDates.astro";
export { default as Description } from "./Description.astro";
export { default as Details } from "./Details.astro";
export { default as DirectoryListing } from "./DirectoryListing.astro";
export { default as Example } from "./Example.astro";
export { default as ExternalResources } from "./ExternalResources.astro";
export { default as Feature } from "./Feature.astro";
export { default as FeatureTable } from "./FeatureTable.astro";
export { default as Glossary } from "./Glossary.astro";
export { default as GlossaryDefinition } from "./GlossaryDefinition.astro";
export { default as GlossaryTooltip } from "./GlossaryTooltip.astro";
export { default as HomepageHero } from "./HomepageHero.astro";
export { default as InlineBadge } from "./InlineBadge.astro";
export { default as LastReviewed } from "./LastReviewed.astro";
export { default as LearningPath } from "./LearningPath.astro";
export { default as LinkTitleCard } from "./LinkTitleCard.astro";
export { default as ListExamples } from "./ListExamples.astro";
export { default as ListTutorials } from "./ListTutorials.astro";
export { default as Markdown } from "./Markdown.astro";
export { default as NetworkMap } from "./NetworkMap.astro";
export { default as PagesBuildEnvironment } from "./PagesBuildEnvironment.astro";
export { default as PagesBuildEnvironmentLanguages } from "./PagesBuildEnvironmentLanguages.astro";
export { default as PagesBuildEnvironmentTools } from "./PagesBuildEnvironmentTools.astro";
export { default as PagesBuildPreset } from "./PagesBuildPreset.astro";
export { default as PagesBuildPresetsTable } from "./PagesBuildPresetsTable.astro";
export { default as PagesLanguageSupport } from "./PagesLanguageSupport.astro";
export { default as Plan } from "./Plan.astro";
export { default as PlanInfo } from "./PlanInfo.astro";
export { default as ProductChangelog } from "./ProductChangelog.astro";
export { default as ProductFeatures } from "./ProductFeatures.astro";
export { default as ProductsByTag } from "./ProductsByTag.astro";
export { default as PublicStats } from "./PublicStats.astro";
export { default as RelatedProduct } from "./RelatedProduct.astro";
export { default as Render } from "./Render.astro";
export { default as ResourcesBySelector } from "./ResourcesBySelector.astro";
export { default as RuleID } from "./RuleID.astro";
export { default as SpotlightAuthorDetails } from "./SpotlightAuthorDetails.astro";
export { default as Stream } from "./Stream.astro";
export { default as ThreeCardGrid } from "./ThreeCardGrid.astro";
export { default as TroubleshootingList } from "./TroubleshootingList.astro";
export { default as TunnelCalculator } from "./TunnelCalculator.astro";
export { default as WorkersAIModels } from "./WorkersAIModels.astro";
export { default as WorkersArchitectureDiagram } from "./WorkersArchitectureDiagram.astro";
export { default as WorkersIsolateDiagram } from "./WorkersIsolateDiagram.astro";
export { default as WorkerStarter } from "./WorkerStarter.astro";
export { default as YouTube } from "./YouTube.astro";

// Taken from Astro
export { default as ListCard } from "./astro/ListCard.astro"
export { default as FourCardGrid } from "./FourCardGrid.astro"
export { default as ListCard } from "./astro/ListCard.astro";
export { default as FourCardGrid } from "./FourCardGrid.astro";

// Homepage
export { default as FeaturedContentSection } from "./homepage/FeaturedContentSection.astro"
export { default as FooterHeroBlock } from "./homepage/FooterHeroBlock.astro"
export { default as RecommendedContentSection } from "./homepage/RecommendedContentSection.astro"
export { default as TryItSection } from "./homepage/TryItSection.astro"
export { default as FeaturedContentSection } from "./homepage/FeaturedContentSection.astro";
export { default as FooterHeroBlock } from "./homepage/FooterHeroBlock.astro";
export { default as RecommendedContentSection } from "./homepage/RecommendedContentSection.astro";
export { default as TryItSection } from "./homepage/TryItSection.astro";
3 changes: 2 additions & 1 deletion src/content/docs/1.1.1.1/check.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ title: Verify connection
sidebar:
order: 6
slug: 1.1.1.1/check

---

import { PublicStats } from "~/components";

After setting up `1.1.1.1`, you can check if you are correctly connected to Cloudflare's resolver.

1. Open a web browser on a configured device (smartphone or computer) or on a device connected to your configured router.
Expand Down
23 changes: 23 additions & 0 deletions src/content/docs/style-guide/components/public-stats.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: Public stats
---

The `PublicStats` component allows you to reference specific values about Cloudflare's network without maintaining those values in multiple files.

Refer to the examples below for more information.

```mdx live
import { PublicStats } from "~/components";

Cloudflare has data centers in <PublicStats id="data_center_cities" />.

Our network has <PublicStats id="total_bandwidth" />.

Cloudflare also has <PublicStats id="network_peers" />.
```

:::note

If you need more stats or to update these stats, submit a pull request to update [PublicStats.astro](https://github.com/cloudflare/cloudflare-docs/blob/production/src/components/PublicStats.astro)

:::

0 comments on commit 3ea1943

Please sign in to comment.