Skip to content

Commit

Permalink
PlatformIdentifier should fall back to guides' platform case style (#…
Browse files Browse the repository at this point in the history
…9187)

Fixes #9051
  • Loading branch information
mjq committed Feb 21, 2024
1 parent c7e5cc0 commit 7365cba
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/components/platformIdentifier.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,24 @@ function formatCaseStyle(style: PlatformCaseStyle | undefined, value: string) {

export function PlatformIdentifier({name, platform}: Props) {
const {rootNode, path} = serverContext();
let currentPlatformOrGuide = rootNode && getCurrentPlatformOrGuide(rootNode, path);
if (!rootNode) {
return null;
}

let currentPlatformOrGuide = getCurrentPlatformOrGuide(rootNode, path);
if (!currentPlatformOrGuide && platform) {
currentPlatformOrGuide = rootNode && getPlatform(rootNode, platform);
currentPlatformOrGuide = getPlatform(rootNode, platform);
}
if (!currentPlatformOrGuide) {
return null;
}

return <code>{formatCaseStyle(currentPlatformOrGuide.caseStyle, name)}</code>;
// For guides, fall back to the parent platform's case style.
let caseStyle = currentPlatformOrGuide.caseStyle;
if (!caseStyle && currentPlatformOrGuide.type === 'guide') {
const parent = getPlatform(rootNode, currentPlatformOrGuide.platform);
caseStyle = parent?.caseStyle;
}

return <code>{formatCaseStyle(caseStyle, name)}</code>;
}

0 comments on commit 7365cba

Please sign in to comment.