Skip to content

Commit 2acef48

Browse files
committed
Add in code examples for metadata
1 parent 6c12034 commit 2acef48

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

src/content/docs/style-guide/how-we-docs/metadata.mdx

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ meta:
55
title: Metadata | How we docs
66
---
77

8+
import { GitHubCode } from "~/components";
9+
810
Page-level metadata - content type, associated products, last updated, word count - lets you take a broader, more strategic view of your content.
911

1012
It helps you answer questions like the following:
@@ -47,13 +49,30 @@ We set these values at two different levels, the folder level and the page level
4749

4850
We set two values at a folder level, `Product` and `Product Group`. We take this approach because we can assume that these values apply every page within that folder.
4951

50-
{/* GitHubCode example of a product.yaml file */}
52+
For example, here's the content from our [DNS folder](https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/products/dns.yaml).
53+
54+
<GitHubCode
55+
repo="cloudflare/cloudflare-docs"
56+
file="src/content/products/dns.yaml"
57+
commit="eeb4aadac6e1ca1f25f698385c1217cabda1adac"
58+
lang="yaml"
59+
code={{ title: "dns.yaml", mark: [4, 6] }}
60+
/>
5161

5262
### Page-level attributes
5363

5464
We primarily set page-level attributes through the [page's frontmatter](/style-guide/frontmatter/custom-properties/).
5565

56-
{/* GitHubCode example of a specific file with a lot of them */}
66+
For example, here are the values set for our [Build a Slackbot tutorial](/workers/tutorials/build-a-slackbot/).
67+
68+
<GitHubCode
69+
repo="cloudflare/cloudflare-docs"
70+
file="src/content/docs/workers/tutorials/build-a-slackbot/index.mdx"
71+
commit="c33f3a8f71fd7b8c7d68d9f0b179abdc1e8d330a"
72+
lang="mdx"
73+
lines="1-10"
74+
code={{ title: "build-a-slackbot.mdx", mark: [2, 4, 6, 7] }}
75+
/>
5776

5877
However, the `last_modified` value is pulled automatically from the git history of a file.
5978

@@ -73,9 +92,16 @@ For example, these are the `meta` properties and values on the [AI Audit - Get S
7392
<meta name="pcx_last_modified" content="7" >
7493
```
7594

76-
We render these values using a custom override for our [`Head.astro`]() file.
95+
We render these values using a custom override for our [`Head.astro`](https://github.com/cloudflare/cloudflare-docs/blob/production/src/components/overrides/Head.astro) file. If specific values are set, we then add them as meta tags onto the page.
7796

78-
{/* GitHubCode for Head.astro */}
97+
<GitHubCode
98+
repo="cloudflare/cloudflare-docs"
99+
file="src/components/overrides/Head.astro"
100+
commit="80573b88bd2a491240e404938feb506d347093db"
101+
lang="ts"
102+
lines="65-72"
103+
code={{ title: "Head.astro" }}
104+
/>
79105

80106
### Benefits
81107

@@ -91,14 +117,6 @@ Additionally, this decisions means that our GitHub repo is always the source of
91117

92118
It's difficult to avoid errors with this kind of metadata, specifically because we are relying on freeform text entry in the frontmatter of individual files.
93119

94-
We utilize `zod` schemas heavily in our Astro site, which are defined at [tbd](/tbd/).
120+
We utilize [Zod schemas](https://zod.dev/) heavily in our Astro site, which are defined in [`src/schemas/`](https://github.com/cloudflare/cloudflare-docs/tree/production/src/schemas).
95121

96122
These allow us to provide Intellisense guidance for contributors using IDEs for local development.
97-
98-
### Optional or required
99-
100-
At the moment, most of our Zod schemas are purely optional, meaning that they will not cause a build to fail.
101-
102-
However, we do have one value, `tags`, that we enforce an allowlist as part of our schema validation. We enforce this schema specifically because we render it as a customer-facing facet for our [search page](/search/), meaning that typos are more disruptive than for other types of metadata.
103-
104-
To try and make this list a bit more flexible, we've included `alternate` values that can lead to the same presented value.

0 commit comments

Comments
 (0)