Skip to content

Commit

Permalink
[v4] if filePath is falsy in client wrapper -> do not render `edit …
Browse files Browse the repository at this point in the history
…on github` link / if `filePath` starts with `http` do not append `docsRepositoryBase` prefix (#3850)

- if `filePath` is falsy in client wrapper -> do not render `edit on github` link
- if `filePath` starts with `http` do not append `docsRepositoryBase` prefix
  • Loading branch information
dimaMachina authored Dec 20, 2024
1 parent 7b153bd commit 25c33dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/khaki-hats-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"nextra-theme-docs": patch
---

- if `filePath` is falsy in client wrapper -> do not render `edit on github` link
- if `filePath` starts with `http` do not append `docsRepositoryBase` prefix
8 changes: 6 additions & 2 deletions packages/nextra-theme-docs/src/components/toc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,14 @@ export const TOC: FC<TOCProps> = ({ toc, filePath, pageTitle }) => {
</Anchor>
)}

{themeConfig.editLink && (
{filePath && themeConfig.editLink && (
<Anchor
className={linkClassName}
href={`${gitUrlParse(themeConfig.docsRepositoryBase).href}/${filePath}`}
href={
filePath.startsWith('http')
? filePath
: `${gitUrlParse(themeConfig.docsRepositoryBase).href}/${filePath}`
}
>
{themeConfig.editLink}
</Anchor>
Expand Down

0 comments on commit 25c33dd

Please sign in to comment.