Skip to content

Commit

Permalink
fix broken edit links
Browse files Browse the repository at this point in the history
  • Loading branch information
rezrah committed Dec 1, 2023
1 parent 0b93ec2 commit 4cb27ae
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/site/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module.exports = {
basePath: process.env.GITHUB_ACTIONS === 'true' ? '/nextocat' : '',
publicRuntimeConfig: {
siteTitle: 'Primer Nextocat',
docsRepositoryBase: 'https://github.com/primer/nextocat',
repo: 'https://github.com/primer/nextocat',
repoSrcPath: 'packages/site', // folder path to your site root. Helpful for monorepos.
sidebarLinks: [
{
title: 'GitHub',
Expand Down
6 changes: 3 additions & 3 deletions packages/theme/components/layout/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ export function Sidebar({pageMap}: SidebarProps) {
if (item.kind === 'Folder') {
const indexPage = item.children.find(child => child.kind === 'MdxPage' && child.name === 'index') as MdxFile
const subNavName = indexPage.frontMatter.title
const shouldHideTabbedPages = indexPage.frontMatter['show-tabs'] || false
const shouldShowTabs = indexPage.frontMatter['show-tabs'] || false

if (shouldHideTabbedPages) {
if (shouldShowTabs) {
return (
<NavList.Item key={indexPage.name} href={`${basePath}${indexPage.route}`}>
{(indexPage as MdxFile).frontMatter?.title || item.name}
Expand Down Expand Up @@ -120,7 +120,7 @@ export function Sidebar({pageMap}: SidebarProps) {

return (
<NavList.Item
key={(landingPageItem as MdxFile).name}
key={`${(landingPageItem as MdxFile).route}`}
href={`${basePath}${(landingPageItem as MdxFile).route}`}
sx={{textTransform: 'capitalize'}}
>
Expand Down
6 changes: 5 additions & 1 deletion packages/theme/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ export default function Layout({children, pageOpts}: NextraThemeLayoutProps) {
<Stack direction="horizontal" padding="none" alignItems="center" gap={8}>
<PencilIcon size={16} fill="var(--brand-InlineLink-color-rest)" />

<InlineLink href={`https://github.com/primer/nextocat/blob/main/${filePath}`}>
<InlineLink
href={`${publicRuntimeConfig.repo}/blob/main/${
publicRuntimeConfig.repoSrcPath ? `${publicRuntimeConfig.repoSrcPath}/` : ''
}${filePath}`}
>
Edit this page
</InlineLink>
</Stack>
Expand Down

0 comments on commit 4cb27ae

Please sign in to comment.