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.
- Generate a typed
productMapkeyed by product ID for routing, context middleware, and robots blocking. - Derive product group data for the homepage hero/cards, with localization support.
- Provide stable product name mappings (e.g., Enterprise Server releases) for rendering and telemetry.
- Excludes: authoring guidance for product content (see
content/), TOC authoring, and versioning docs (seesrc/versions).
lib/all-products.ts: Readscontent/index.mdfrontmatter, buildsproductMap(id, name, href, dir, toc, wip, hidden, versions, external) andproductIds; mutates later via middleware to addnameRendered.lib/get-product-groups.ts: Builds homepage product group structures; resolves localized names via translatedcontent/index.mdwhen present.lib/product-names.ts: Maps product codes (dotcom, GHES versions) to display names.lib/old-developer-products.json: Legacy list used for migration/compat checks.- Tests under
tests/validate schemas, product map shape, group helpers, and name mappings.
- Source:
content/index.mdfrontmatter.children: array of product IDs (directory names undercontent/).childGroups: array of groups{ name, icon?, octicon?, children[] }for homepage cards; children entries can be product IDs or deeper paths.externalProducts(optional): map of product IDs to product objects matchingProductshape; used to surface external docs.
- Product object shape (see
Productinlib/all-products.ts):id,name(title or shortTitle),href(first applicable version),dir,toc,wip,hidden,versions(computed), optionalexternal, optionalnameRendered(added by middleware).
- Localization: For product groups, localized
content/index.mdfrontmatter (same keys) is read if available; structure is always taken from English, names can be swapped viaocticonmatching.
- Server context middleware loads
productMapintoreq.contextfor routing, version checks, and rendering product names. get-product-groupsis used to render homepage product cards with localized names when available.productMapdrives robots blocking (wip/hidden), nav generation (get-toc-items), and page validation (parent product assertions).
- Update
content/index.mdto add or reorder products and product groups; ensure new product directories haveindex.mdwith frontmatter (title/shortTitle,versions, optionalwip/hidden). - To add an external product, define it under
externalProductsincontent/index.md. External products should include as manyProductfields as applicable (such asid,name,href), but some fields (likeversions) may be omitted. - For localized group names, add translated
content/index.mdwith matchingchildGroupsandocticonkeys.
- Full subject tests:
npm test -- src/products/tests - Targeted:
products.tsvalidatesproductMapschema and presence of expected product IDs.get-product-groups.tscovers group helper mapping and localization.product-names.tschecks display name mappings.
- Owners: Docs Engineering. Content changes (titles, grouping, product lists) coordinated with docs-content.
- State: KTLO; update when products are added/retired or homepage groups change.