Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ export const componentImports: Readonly<Record<Component, string>> = {
Supademo: '@site/src/components/Supademo',
Procedures: '@site/src/components/Procedures',
DocCardList: '@theme/DocCardList',
Grid: '@site/src/components/Grid',
}

/** Canonical emission order; imports are deduplicated and emitted once. */
export const componentOrder: readonly Component[] = ['Admonition', 'Tabs', 'TabItem', 'Supademo', 'Procedures', 'DocCardList']
export const componentOrder: readonly Component[] = ['Admonition', 'Tabs', 'TabItem', 'Supademo', 'Procedures', 'DocCardList', 'Grid']

/** True when the generator knows how to import this authored component. */
export const isImportableComponent = (name: string): name is Component => name in componentImports
Expand Down
2 changes: 1 addition & 1 deletion packages/docs-tooling/src/shared-docs/core/site/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { DiagnosticContext, PageConfig, SharedDocsError } from '../types'

export interface TabsLanguage { value: string; label: string; aliases?: readonly string[]; required?: boolean; fence?: string }
export interface TabsRules { schema_version: 1; group_id: string; default: string; languages: readonly TabsLanguage[] }
export type Component = 'Admonition' | 'Tabs' | 'TabItem' | 'Supademo' | 'Procedures' | 'DocCardList'
export type Component = 'Admonition' | 'Tabs' | 'TabItem' | 'Supademo' | 'Procedures' | 'DocCardList' | 'Grid'
export interface AdaptPageInput {
markdown: string
pageId: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ it('detects authored component tags and emits their imports once', async () => {
expect(await toMdx(result, context)).toHaveProperty('mdx')
})

it('detects <Grid> components and emits @site/src/components/Grid once', async () => {
const result = adapted(page('<Grid columnSize="2">\n\nCard A\n\n</Grid>\n\n<Grid columnSize="2">\n\nCard B\n\n</Grid>'))
expect(result.components).toEqual(['Grid'])
expect(result.markdown.match(/^import Grid from '@site\/src\/components\/Grid';$/gm)).toHaveLength(1)
expect(await toMdx(result, context)).toHaveProperty('mdx')
})

it('preserves globally registered <UI> tags across paragraphs, lists and NextChannel without emitting an import', async () => {
const body = [
'Click <UI>Create Cluster</UI>.',
Expand Down