Skip to content
Open
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
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore the config, later after testing I will revert these files to originals.

Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export default {
platformUrl: { table: { category: 'Input' } },
},
args: {
projectId: 'cHJqOjYwNjYx',
platformUrl: 'https://stoplight.io',
projectId: 'cHJqOjMwODc1MA',
platformUrl: 'https://persistentteams.stoplight.io',
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ export default {
},
args: {
nodeSlug: 'b3A6Mzg5NDM2-create-todo',
projectId: 'cHJqOjYwNjYx',
projectId: 'cHJqOjMwODc1MA',
branchSlug: '',
platformUrl: 'https://stoplight.io',
platformUrl: 'https://persistentteams.stoplight.io',
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ export default {
isInResponsiveMode: { table: { category: 'Input' } },
},
args: {
projectIds: ['cHJqOjYwNjYx'],
projectIds: ['cHJqOjMwODc1MA'],
workspaceId: 'd2s6NDE1NTU',
platformUrl: 'https://stoplight.io',
platformUrl: 'https://persistentteams.stoplight.io',
isInResponsiveMode: false,
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ export default {
isInResponsiveMode: { table: { category: 'Input' } },
},
args: {
projectId: 'cHJqOjYwNjYx',
projectId: 'cHJqOjMwODc1MA',
branchSlug: '',
platformUrl: 'https://stoplight.io',
platformUrl: 'https://persistentteams.stoplight.io',
isInResponsiveMode: false,
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ export default {
},
args: {
router: 'memory',
platformUrl: 'https://stoplight.io',
platformUrl: 'https://persistentteams.stoplight.io',
},
};

export const Playground: Story<StoplightProjectProps> = args => <StoplightProject {...args} />;
Playground.storyName = 'Studio Demo';
Playground.args = {
projectId: 'cHJqOjYwNjYx',
platformUrl: 'https://stoplight.io',
projectId: 'cHJqOjMwODc1MA',
platformUrl: 'https://persistentteams.stoplight.io',
};
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ const StoplightProjectImpl: React.FC<StoplightProjectProps> = ({ projectId, coll

const container = React.useRef<HTMLDivElement>(null);

// Create a custom Link component that preserves the branch path
const BranchAwareLink = React.useMemo(() => {
return React.forwardRef<HTMLAnchorElement, React.ComponentProps<typeof Link>>((props, ref) => {
const { to, ...rest } = props;
// If we're on a branch, prefix all relative links with the branch path
// Only modify relative paths (not starting with /, #, http://, https://, or .)
const shouldPrefixBranch = branchSlug && typeof to === 'string' && to !== '.' && !/^(\/|#|https?:\/\/)/.test(to);

const adjustedTo = shouldPrefixBranch ? `branches/${encodeURIComponent(branchSlug)}/${to}` : to;
return <Link ref={ref} to={adjustedTo} {...rest} />;
});
}, [branchSlug]);

if (!nodeSlug && isTocFetched && tableOfContents?.items) {
const firstNode = findFirstNode(tableOfContents.items);
if (firstNode) {
Expand Down Expand Up @@ -152,7 +165,7 @@ const StoplightProjectImpl: React.FC<StoplightProjectProps> = ({ projectId, coll
<TableOfContents
activeId={node?.id || nodeSlug?.split('-')[0] || ''}
tableOfContents={tableOfContents}
Link={Link as CustomLinkComponent}
Link={BranchAwareLink as CustomLinkComponent}
collapseTableOfContents={collapseTableOfContents}
onLinkClick={handleTocClick}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ export default {
export const defaultProject = Template.bind({});
defaultProject.storyName = "Stoplight's Demo workspace";
defaultProject.args = {
projectId: 'cHJqOjYwNjYx',
platformUrl: 'https://stoplight.io',
projectId: 'cHJqOjMwODc1MA',
platformUrl: 'https://persistentteams.stoplight.io',
};