Skip to content

Commit 225febc

Browse files
committed
Image maintenance
1 parent 1590890 commit 225febc

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

src/content/docs/style-guide/how-we-docs/image-maintenance.mdx

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,62 @@ title: Image maintenance
44
meta:
55
title: Image maintenance | How we docs
66
---
7+
8+
import { GitHubCode } from "~/components";
9+
10+
Though valuable for user understanding, images are difficult to maintain. We have a few strategies that we use to help make this easier.
11+
12+
## Guidelines
13+
14+
We support a few different types of images in our docs, including:
15+
16+
- [Diagrams](/style-guide/documentation-content-strategy/component-attributes/diagrams/)
17+
- [Mermaid diagrams](/style-guide/components/mermaid/)
18+
- Screenshots
19+
20+
Of these, we prefer Mermaid diagrams because they are searchable and changeable. The "cost" of updating a Mermaid diagram is much lower than re-taking a screenshot or working with a designer to update a diagram.
21+
22+
Additionally, you should only use screenshots intentionally, such as when there's a clear user confusion that needs a visual image. [Find account and zone ID](/fundamentals/account/find-account-and-zone-ids/) is a good illustration of this, because it's a common user pain point and one that's very difficult in the current Cloudflare UI.
23+
24+
## Maintenance
25+
26+
The best way to improve image maintenance is to avoid using them.
27+
28+
The other way to streamline maintenance is to remove images that are no longer referenced in your documentation. This pattern becomes particularly helpful if you need to audit images for UI changes or leaked information, because then you are not wasting time looking at unused images too.
29+
30+
We do that through a combination of GitHub actions.
31+
32+
### Flag unused images
33+
34+
We have a specific GitHub action to [flag unused images](https://github.com/cloudflare/cloudflare-docs/blob/production/.github/workflows/image-audit.yml).
35+
36+
What it does is:
37+
38+
1. Finds all `.png` or `.svg` files in our content.
39+
2. Checks to see if those files are referenced in any of our MDX files.
40+
3. If there are unreferenced files, creates a [GitHub issue](https://github.com/cloudflare/cloudflare-docs/issues/23343) listing them out.
41+
42+
### Evaluate image paths
43+
44+
In combination with [flagging unused images](#flag-unused-images), we also have logic in our [build process](https://github.com/cloudflare/cloudflare-docs/blob/production/astro.config.ts) to validate image paths.
45+
46+
<GitHubCode
47+
repo="cloudflare/cloudflare-docs"
48+
file="astro.config.ts"
49+
commit="aaacc3c3c2a7517ee307ddfc56962cbea9847202"
50+
lang="ts"
51+
lines="62-76"
52+
code={{ title: "astro.config.ts", mark: 5 }}
53+
/>
54+
55+
This line ensures that our custom [Remark plugin](https://github.com/cloudflare/cloudflare-docs/blob/production/src/plugins/remark/validate-images.ts) validates all images paths. If the path does not exist, we throw an error and prevent the site from building.
56+
57+
<GitHubCode
58+
repo="cloudflare/cloudflare-docs"
59+
file="src/plugins/remark/validate-images.ts"
60+
commit="fdeaadcfa99030d085512e721bc0a5948dcf70d4"
61+
lang="ts"
62+
code={{ title: "validate-images.ts" }}
63+
/>
64+
65+
When paired with [flagging unused images](#flag-unused-images), this path validation ensures that a tech writer can safely delete unused files in a PR. So long as the site builds correctly, you have only deleted image files that are not referenced anywhere.

0 commit comments

Comments
 (0)