1- // Canonical mapping of internal schema kinds to:
2- // - urlKind: the URL/folder segment used in href anchors before categorization
3- // (kept for backward-compat with `helpers.getFullLink` signature)
4- // - slugPrefix: the kind-disambiguating slug prefix used on category pages
5- // so two items sharing a case-insensitive name don't collide
6- // - label: human-readable label rendered as a Primer Label next to each item
1+ // Schema kind tables keep legacy URL segments, category-page slug prefixes, and visible labels.
72
83export type SchemaKindKey =
94 | 'queries'
@@ -26,8 +21,7 @@ export const KIND_LABELS: Record<SchemaKindKey, string> = {
2621 scalars : 'Scalar' ,
2722}
2823
29- // Plural form of `KIND_LABELS`, used as the section heading (and mini-TOC
30- // parent label) when a GraphQL category page groups its items by kind.
24+ // Plural labels appear in category-page sections and mini-TOC section entries.
3125export const KIND_LABELS_PLURAL : Record < SchemaKindKey , string > = {
3226 queries : 'Queries' ,
3327 mutations : 'Mutations' ,
@@ -39,10 +33,7 @@ export const KIND_LABELS_PLURAL: Record<SchemaKindKey, string> = {
3933 scalars : 'Scalars' ,
4034}
4135
42- // Slug prefix used to disambiguate items across kinds on a category page.
43- // For example, a `Repository` object and a `repository` query both have id
44- // `repository`; on a category page they become `object-repository` and
45- // `query-repository` respectively.
36+ // Category-page anchors prefix the kind, so Repository object and repository query stay distinct.
4637export const KIND_SLUG_PREFIX : Record < SchemaKindKey , string > = {
4738 queries : 'query' ,
4839 mutations : 'mutation' ,
@@ -54,9 +45,8 @@ export const KIND_SLUG_PREFIX: Record<SchemaKindKey, string> = {
5445 scalars : 'scalar' ,
5546}
5647
57- // The "URL kind" / `pageType` value used by `helpers.getTypeKind` and
58- // `helpers.getFullLink`. `inputObjects` (camelCase internal key) becomes
59- // `input-objects` in URLs.
48+ // These URL segments match helpers.getTypeKind output and helpers.getFullLink input.
49+ // For example, inputObjects becomes input-objects.
6050export const KIND_URL_SEGMENT : Record < SchemaKindKey , string > = {
6151 queries : 'queries' ,
6252 mutations : 'mutations' ,
@@ -79,28 +69,22 @@ export const ALL_KIND_KEYS: SchemaKindKey[] = [
7969 'scalars' ,
8070]
8171
82- // Reverse map from the URL-kind segment used in hrefs (e.g. `input-objects`)
83- // to the slug prefix used to disambiguate items in category page anchors
84- // (e.g. `input-object`). Derived from KIND_URL_SEGMENT + KIND_SLUG_PREFIX so
85- // the three tables stay in sync automatically.
72+ // Derive URL-segment to slug-prefix mappings from the source tables so anchor helpers stay in sync.
73+ // For example, input-objects maps to input-object.
8674export const SLUG_PREFIX_BY_URL_SEGMENT : Record < string , string > = Object . fromEntries (
8775 ALL_KIND_KEYS . map ( ( k ) => [ KIND_URL_SEGMENT [ k ] , KIND_SLUG_PREFIX [ k ] ] ) ,
8876)
8977
90- // Given a URL-kind segment (as returned by helpers.getTypeKind, e.g.
91- // `objects`, `input-objects`), return the slug prefix used to disambiguate
92- // items in category page anchors. Falls back to the input for unknown kinds.
78+ // Unknown URL-kind segments fall back to themselves so callers can handle future kinds.
9379export function slugPrefixForUrlKind ( urlKind : string ) : string {
9480 return SLUG_PREFIX_BY_URL_SEGMENT [ urlKind ] ?? urlKind
9581}
9682
97- // Bucket all items that don't have an upstream `@docsCategory` directive .
83+ // Unannotated upstream schema items fall into the other category .
9884export const OTHER_CATEGORY = 'other'
9985
100- // Canonical list of categories emitted by the upstream `docs_category` DSL.
101- // Keep this list in sync with the allowlist in
102- // `github/github`'s `app/platform/objects/base/docs_category.rb`.
103- // `other` is a docs-internal bucket for un-annotated types.
86+ // github/github app/platform/objects/base/docs_category.rb must allow each upstream category here.
87+ // The other category belongs to docs-internal for unannotated types.
10488export const CATEGORIES = [
10589 'actions' ,
10690 'activity' ,
@@ -153,7 +137,6 @@ export function isValidCategory(slug: string): slug is CategorySlug {
153137 return ( CATEGORIES as readonly string [ ] ) . includes ( slug )
154138}
155139
156- // Human-readable display title for a category. Falls back to slug.
157140export function categoryTitle ( slug : string ) : string {
158141 switch ( slug ) {
159142 case 'apps' :
0 commit comments