Skip to content

Commit

Permalink
feat(docs): support logoLink config option (#905)
Browse files Browse the repository at this point in the history
  • Loading branch information
tknickman committed Oct 18, 2022
1 parent 6b3e1a4 commit 5238bb4
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/olive-otters-float.md
@@ -0,0 +1,5 @@
---
"nextra-theme-docs": patch
---

feat(docs): support logoLink config option
30 changes: 30 additions & 0 deletions examples/docs/src/pages/themes/docs/configuration.mdx
Expand Up @@ -355,6 +355,36 @@ export default {
}
```

## `logoLink`

Enable automaticaly linking the logo to root, or provide a custom url.

**Type:** `string` | `boolean`

**Default:** `true` (links to `/` by default)

**Example:**

```js filename="theme.config.js"
/**
* @type {import('nextra-theme-docs').DocsThemeConfig}
*/
export default {
logoLink: '/about'
}
```

Or to disable the logo link:

```js filename="theme.config.js"
/**
* @type {import('nextra-theme-docs').DocsThemeConfig}
*/
export default {
logoLink: false
}
```

## `head`

The head that should be inserted into the html document.
Expand Down
19 changes: 12 additions & 7 deletions packages/nextra-theme-docs/src/components/navbar.tsx
Expand Up @@ -94,13 +94,18 @@ export function Navbar({ flatDirectories, items }: NavBarProps): ReactElement {
)}
/>
<nav className="mx-auto flex h-[var(--nextra-navbar-height)] max-w-[90rem] items-center justify-end gap-2 pl-[max(env(safe-area-inset-left),1.5rem)] pr-[max(env(safe-area-inset-right),1.5rem)]">
<Anchor
href="/"
className="flex ltr:mr-auto rtl:ml-auto items-center hover:opacity-75"
>
{renderComponent(config.logo)}
</Anchor>

{config.logoLink ? (
<Anchor
href={typeof config.logoLink === 'string' ? config.logoLink : '/'}
className="flex ltr:mr-auto rtl:ml-auto items-center hover:opacity-75"
>
{renderComponent(config.logo)}
</Anchor>
) : (
<div className="flex ltr:mr-auto rtl:ml-auto items-center">
{renderComponent(config.logo)}
</div>
)}
{items.map(pageOrMenu => {
if (pageOrMenu.hidden) return null

Expand Down
1 change: 1 addition & 0 deletions packages/nextra-theme-docs/src/constants.tsx
Expand Up @@ -87,6 +87,7 @@ export const DEFAULT_THEME: DocsThemeConfig = {
</span>
</>
),
logoLink: true,
main: {
extraContent: null
},
Expand Down
1 change: 1 addition & 0 deletions packages/nextra-theme-docs/src/types.ts
Expand Up @@ -50,6 +50,7 @@ export interface DocsThemeConfig {
head: ReactNode | FC
i18n: { direction?: string; locale: string; text: string }[]
logo: ReactNode | FC
logoLink?: boolean | string
main: {
extraContent: ReactNode | FC
}
Expand Down

0 comments on commit 5238bb4

Please sign in to comment.