|
1 | | -❤︎ |
| 1 | +# Products |
| 2 | + |
| 3 | +Utilities that read product metadata from `content/index.md`, build the product map used for navigation and context, and help group products for the home page. This README covers purpose, contracts, usage, workflows, testing, and ownership for the `src/products` subject. |
| 4 | + |
| 5 | +## Purpose & scope |
| 6 | +* Generate a typed `productMap` keyed by product ID for routing, context middleware, and robots blocking. |
| 7 | +* Derive product group data for the homepage hero/cards, with localization support. |
| 8 | +* Provide stable product name mappings (e.g., Enterprise Server releases) for rendering and telemetry. |
| 9 | +* Excludes: authoring guidance for product content (see `content/`), TOC authoring, and versioning docs (see `src/versions`). |
| 10 | + |
| 11 | +## Architecture & key assets |
| 12 | +* `lib/all-products.ts`: Reads `content/index.md` frontmatter, builds `productMap` (id, name, href, dir, toc, wip, hidden, versions, external) and `productIds`; mutates later via middleware to add `nameRendered`. |
| 13 | +* `lib/get-product-groups.ts`: Builds homepage product group structures; resolves localized names via translated `content/index.md` when present. |
| 14 | +* `lib/product-names.ts`: Maps product codes (dotcom, GHES versions) to display names. |
| 15 | +* `lib/old-developer-products.json`: Legacy list used for migration/compat checks. |
| 16 | +* Tests under `tests/` validate schemas, product map shape, group helpers, and name mappings. |
| 17 | + |
| 18 | +## Data contracts |
| 19 | +* Source: `content/index.md` frontmatter. |
| 20 | + * `children`: array of product IDs (directory names under `content/`). |
| 21 | + * `childGroups`: array of groups `{ name, icon?, octicon?, children[] }` for homepage cards; children entries can be product IDs or deeper paths. |
| 22 | + * `externalProducts` (optional): map of product IDs to product objects matching `Product` shape; used to surface external docs. |
| 23 | +* Product object shape (see `Product` in `lib/all-products.ts`): |
| 24 | + * `id`, `name` (title or shortTitle), `href` (first applicable version), `dir`, `toc`, `wip`, `hidden`, `versions` (computed), optional `external`, optional `nameRendered` (added by middleware). |
| 25 | +* Localization: For product groups, localized `content/index.md` frontmatter (same keys) is read if available; structure is always taken from English, names can be swapped via `octicon` matching. |
| 26 | + |
| 27 | +## Usage |
| 28 | +* Server context middleware loads `productMap` into `req.context` for routing, version checks, and rendering product names. |
| 29 | +* `get-product-groups` is used to render homepage product cards with localized names when available. |
| 30 | +* `productMap` drives robots blocking (wip/hidden), nav generation (`get-toc-items`), and page validation (parent product assertions). |
| 31 | + |
| 32 | +## Workflows |
| 33 | +* Update `content/index.md` to add or reorder products and product groups; ensure new product directories have `index.md` with frontmatter (`title`/`shortTitle`, `versions`, optional `wip`/`hidden`). |
| 34 | +* To add an external product, define it under `externalProducts` in `content/index.md`. External products should include as many `Product` fields as applicable (such as `id`, `name`, `href`), but some fields (like `versions`) may be omitted. |
| 35 | +* For localized group names, add translated `content/index.md` with matching `childGroups` and `octicon` keys. |
| 36 | + |
| 37 | +## Testing |
| 38 | +* Full subject tests: `npm test -- src/products/tests` |
| 39 | +* Targeted: |
| 40 | + * `products.ts` validates `productMap` schema and presence of expected product IDs. |
| 41 | + * `get-product-groups.ts` covers group helper mapping and localization. |
| 42 | + * `product-names.ts` checks display name mappings. |
| 43 | + |
| 44 | +## Ownership & current state |
| 45 | +* Owners: Docs Engineering. Content changes (titles, grouping, product lists) coordinated with docs-content. |
| 46 | +* State: KTLO; update when products are added/retired or homepage groups change. |
0 commit comments