Skip to content

Commit

Permalink
Refactor title generation in Route component and add tag to PathItemO…
Browse files Browse the repository at this point in the history
…peration
  • Loading branch information
jeffdrumgod committed Mar 22, 2024
1 parent d0887fc commit 2f66d02
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/starlight-openapi-rapidoc/components/Route.astro
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,17 @@ if (schema.documentDereferenced !== true) {
}
const isOverview = type === 'overview'
const title = `${schema.config.label} - ${isOverview ? 'Overview' : Astro.props.operation.title}`
const SEPARATOR = '/'
let title = `${schema.config.label}`
if (isOverview) {
title = `${title} ${SEPARATOR} Overview`
} else {
if (Astro.props.operation?.tag) {
title = `${title} ${SEPARATOR} ${Astro.props.operation.tag}`
}
title = `${title} ${SEPARATOR} ${Astro.props.operation.title}`
}
const frontmatter = {
...Astro.props?.frontmatter,
Expand Down
2 changes: 2 additions & 0 deletions packages/starlight-openapi-rapidoc/libs/operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function getOperationsByTag(document: Schema['document']) {
pathItem,
slug: `operations/${slug(operationId)}`,
title: (summary ?? operationId) || pathItemPath || `${description}`.slice(100) || '',
tag,
})

operationsByTag.set(tag, operations)
Expand Down Expand Up @@ -146,6 +147,7 @@ export interface PathItemOperation {
pathItem: PathItem
slug: string
title: string
tag?: string
}

export type Operation = OpenAPI.Operation
Expand Down

0 comments on commit 2f66d02

Please sign in to comment.