Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
louisjoecodes committed Dec 23, 2024
2 parents 7749286 + efe11a9 commit 05b918a
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 4 deletions.
File renamed without changes
File renamed without changes
67 changes: 67 additions & 0 deletions fern/assets/scripts/logo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
function initLogoVisibility() {
function updateLogoVisibility() {
const logoContainer = document.querySelector('.fern-logo-container');
if (!logoContainer) return;

// Logo path mapping based on URL patterns
const logoPathMap = {
'conversational-ai': {
light:
'https://raw.githubusercontent.com/elevenlabs/elevenlabs-docs/refs/heads/feat/docs-content-2-0/fern/assets/logo-light-conversational-ai.svg',
dark: 'https://raw.githubusercontent.com/elevenlabs/elevenlabs-docs/refs/heads/feat/docs-content-2-0/fern/assets/logo-dark-conversational-ai.svg',
},

'api-reference': {
light:
'https://raw.githubusercontent.com/elevenlabs/elevenlabs-docs/refs/heads/feat/docs-content-2-0/fern/assets/logo-light-api-reference.svg',
dark: 'https://raw.githubusercontent.com/elevenlabs/elevenlabs-docs/refs/heads/feat/docs-content-2-0/fern/assets/logo-dark-api-reference.svg',
},
default: {
light:
'https://raw.githubusercontent.com/elevenlabs/elevenlabs-docs/refs/heads/feat/docs-content-2-0/fern/assets/logo-light.svg',
dark: 'https://raw.githubusercontent.com/elevenlabs/elevenlabs-docs/refs/heads/feat/docs-content-2-0/fern/assets/logo-dark.svg',
},
};

let logoVariant = 'default';
// Use router.pathname if available, otherwise fallback to window.location
const currentPath = window.location.pathname;
console.log(currentPath);
if (currentPath.startsWith('/docs/conversational-ai')) {
logoVariant = 'conversational-ai';
} else if (currentPath.startsWith('/docs/api-reference')) {
logoVariant = 'api-reference';
}

// Update existing logo sources if they exist
const lightLogo = logoContainer.querySelector('.fern-logo-light');
const darkLogo = logoContainer.querySelector('.fern-logo-dark');

if (lightLogo) lightLogo.src = logoPathMap[logoVariant].light;
if (darkLogo) darkLogo.src = logoPathMap[logoVariant].dark;
}

// Update on initial load
updateLogoVisibility();

// Listen for Next.js route changes
if (window?.next?.router) {
window.next.router.events.on('routeChangeComplete', updateLogoVisibility);
}

// Fallback to popstate event for non-Next.js navigation
window.addEventListener('popstate', updateLogoVisibility);
}

// Run initialization when router is ready
if (window?.next?.router?.isReady) {
initLogoVisibility();
} else {
window?.next?.router?.events.on('routerChangeComplete', initLogoVisibility);
// Fallback to DOMContentLoaded
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initLogoVisibility);
} else {
initLogoVisibility();
}
}
3 changes: 0 additions & 3 deletions fern/conversational-ai/pages/introduction.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
---
title: Introduction
subtitle: Deploy customized, conversational voice agents in minutes.
logo:
light: https://raw.githubusercontent.com/elevenlabs/elevenlabs-docs/refs/heads/feat/docs-content-2-0/fern/assets/logo-light-conversational-ai.svg
dark: https://raw.githubusercontent.com/elevenlabs/elevenlabs-docs/refs/heads/feat/docs-content-2-0/fern/assets/logo-dark-conversational-ai.svg
---

<iframe
Expand Down
2 changes: 2 additions & 0 deletions fern/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ js:
strategy: lazyOnload
- path: assets/scripts/audio-player.js
strategy: lazyOnload
- path: assets/scripts/logo.js
strategy: lazyOnload
- url: https://elevenlabs.io/player/audioNativeHelper.js
strategy: lazyOnload

Expand Down
4 changes: 3 additions & 1 deletion fern/docs/pages/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ hide-nav-links: true
height="200"
style={{ objectFit: 'cover' }}
/>
Learn how to build with ElevenLabs.

Learn how to integrate ElevenLabs into your apps.

</Card>
<Card title="Conversational AI" href="/docs/changelog">
<img
Expand Down

0 comments on commit 05b918a

Please sign in to comment.