-
-
- Features
-
-
- {bot.features.map((feature, index) => (
- -
-
- {feature}
-
- ))}
-
-
-
-
-
- How It Works
-
-
- -
-
- 1
-
-
-
- Describe your artistic vision
-
-
- Share details about your creative project or style
- preferences.
-
-
-
- -
-
- 2
-
-
-
AI Analysis
-
- Our AI processes your input using art knowledge and
- creative principles.
-
-
-
- -
-
- 3
-
-
-
- Get Creative Insights
-
-
- Receive tailored advice, inspiration, and techniques for
- your artistic endeavors.
-
-
-
-
-
+
+ {({ bot, tryLink }) => (
+ <>
+ {/* Title and Overview */}
+
+
+ {bot.nav!.navTitle}
+
+
{bot.overview}
-
- {/* Style Analysis Tool */}
-
-
- Analyze Your Style
-
-
-
- Describe your artistic work or upload an image for style analysis.
-
-
-
-
-
-
-
-
-
-
-
-
- {/* Art Styles Exploration */}
-
-
- Explore Art Styles
-
-
-
- {[
- {
- style: 'Impressionism',
- description:
- 'Characterized by small, thin brush strokes and emphasis on light and movement.',
- },
- {
- style: 'Cubism',
- description:
- 'Objects are analyzed, broken up and reassembled in an abstracted form.',
- },
- {
- style: 'Surrealism',
- description:
- 'Juxtaposition of uncommon imagery to activate the unconscious mind.',
- },
- ].map((artStyle, index) => (
-
-
-
-
- {artStyle.style}
-
-
{artStyle.description}
-
+ {/* Features Section */}
+
+
+
+
+ Features
+
+
+ {bot.features.map((feature, index) => (
+ -
+
+ {feature}
+
+ ))}
+
- ))}
-
-
- {/* Creative Prompt Generator */}
-
-
- Creative Prompt Generator
-
-
-
- Get a random creative prompt to inspire your next project.
-
-
-
-
- "Create a piece that represents the feeling of nostalgia using
- only three colors."
-
-
-
-
-
-
-
-
-
- {/* CTA Section */}
-
-
-
- Ready to Get Started?
-
-
- Unlock your creative potential with our AI-powered artistic
- advisor.
-
-
-
- Try {nav.navTitle} Now
-
-
+
+ How It Works
+
+
+ -
+
+ 1
+
+
+
+ Describe your artistic vision
+
+
+ Share details about your creative project or style
+ preferences.
+
+
+
+ -
+
+ 2
+
+
+
AI Analysis
+
+ Our AI processes your input using art knowledge and
+ creative principles.
+
+
+
+ -
+
+ 3
+
+
+
+ Get Creative Insights
+
+
+ Receive tailored advice, inspiration, and techniques for
+ your artistic endeavors.
+
+
+
+
+
-
-
-
-
+
+
+ {/* Style Analysis Tool */}
+
+
+ Analyze Your Style
+
+
+
+ Describe your artistic work or upload an image for style analysis.
+
+
+
+
+
+
+
+
+
+
+
+
+ {/* Art Styles Exploration */}
+
+
+ Explore Art Styles
+
+
+
+ {[
+ {
+ style: 'Impressionism',
+ description:
+ 'Characterized by small, thin brush strokes and emphasis on light and movement.',
+ },
+ {
+ style: 'Cubism',
+ description:
+ 'Objects are analyzed, broken up and reassembled in an abstracted form.',
+ },
+ {
+ style: 'Surrealism',
+ description:
+ 'Juxtaposition of uncommon imagery to activate the unconscious mind.',
+ },
+ ].map((artStyle, index) => (
+
+
+
+
+ {artStyle.style}
+
+
{artStyle.description}
+
+
+ ))}
+
+
+
+ {/* Creative Prompt Generator */}
+
+
+ Creative Prompt Generator
+
+
+
+ Get a random creative prompt to inspire your next project.
+
+
+
+
+ "Create a piece that represents the feeling of nostalgia using
+ only three colors."
+
+
+
+
+
+
+
+
+
+ {/* CTA Section */}
+
+
+
+ Ready to Get Started?
+
+
+ Unlock your creative potential with our AI-powered artistic
+ advisor.
+
+
+
+
+ >
+ )}
+
);
}
diff --git a/app/bots/medical-expert/page.tsx b/app/bots/medical-expert/page.tsx
index f61abab..dc16535 100644
--- a/app/bots/medical-expert/page.tsx
+++ b/app/bots/medical-expert/page.tsx
@@ -1,9 +1,6 @@
'use client';
-import React from 'react';
-import { getBotBySlug, getBotTryLink } from '@/data/bots';
-import BotNavigation from '../BotNavigation';
-import { BotSection, BotNotFoundFallback } from '@/components/shared';
+import { BotPageTemplate, BotSection } from '@/components/shared';
import './styles.css';
import HeroSection from './components/hero/HeroSection';
@@ -15,59 +12,42 @@ import FutureProductsSection from './components/future/FutureProductsSection';
import VisionAndJoinSection from './components/vision/VisionAndJoinSection';
export default function MedicalExpert() {
- const bot = getBotBySlug('medical-expert');
- const tryLink = getBotTryLink(bot);
-
- if (!bot || !bot.nav) {
- return
;
- }
-
- const { nav } = bot;
-
return (
-
-
-
-
- tryLink}
- />
-
-
-
-
-
+ {({ bot, tryLink }) => (
+ <>
+ tryLink}
/>
-
-
-
-
+
-
- tryLink} />
-
+
+ tryLink}
+ />
+
-
-
-
+
+
+
-
-
-
-
-
+
+ tryLink} />
+
+
+
+
+
+
+
+
+
+ >
+ )}
+
);
}
diff --git a/app/bots/research-assistant/page.tsx b/app/bots/research-assistant/page.tsx
index 8fff273..82d1179 100644
--- a/app/bots/research-assistant/page.tsx
+++ b/app/bots/research-assistant/page.tsx
@@ -1,9 +1,6 @@
'use client';
-import React from 'react';
-import { getBotBySlug, getBotTryLink } from '@/data/bots';
-import BotNavigation from '../BotNavigation';
-import { BotSection, BotNotFoundFallback } from '@/components/shared';
+import { BotPageTemplate, BotSection } from '@/components/shared';
import './styles.css';
import HeroSection from './components/hero/HeroSection';
@@ -16,68 +13,56 @@ import DiscoverySection from './components/discovery/DiscoverySection';
import IntegrationSection from './components/integration/IntegrationSection';
import DevelopmentRoadmap from './components/integration/DevelopmentRoadmap';
+const WAITLIST_LINK = 'https://nerd.ai/waitlist';
+
export default function ResearchAssistant() {
- const bot = getBotBySlug('research-assistant');
- const tryLink = getBotTryLink(bot);
- const waitlistLink = 'https://nerd.ai/waitlist';
-
- if (!bot || !bot.nav) {
- return
;
- }
-
- const { nav } = bot;
-
return (
-
-
+
+ {({ bot }) => (
+ <>
+ WAITLIST_LINK}
+ />
-
- waitlistLink}
- />
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+ WAITLIST_LINK} />
+
-
- waitlistLink} />
-
+
+
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+ >
+ )}
+
);
}
diff --git a/components/shared/BotPageTemplate.tsx b/components/shared/BotPageTemplate.tsx
new file mode 100644
index 0000000..1c29810
--- /dev/null
+++ b/components/shared/BotPageTemplate.tsx
@@ -0,0 +1,150 @@
+'use client';
+
+import { type FC, type ReactNode, useEffect, useRef } from 'react';
+import { getBotBySlug, getBotTryLink, type Bot } from '@/data/bots';
+import BotNavigation from '@/app/bots/BotNavigation';
+import { BotNotFoundFallback } from './BotNotFoundFallback';
+
+interface BotPageTemplateProps {
+ /** The bot slug to load from data/bots.ts */
+ botSlug: string;
+ /** Display name for fallback if bot not found */
+ botDisplayName: string;
+ /** The main content of the page */
+ children: (props: BotPageRenderProps) => ReactNode;
+ /** Optional: Override the try/chat link */
+ overrideTryLink?: string;
+ /** Optional: Custom CSS file imported by the page */
+ className?: string;
+ /** Optional: Include scroll-to-hash behavior */
+ enableHashScrolling?: boolean;
+ /** Optional: Include footer */
+ showFooter?: boolean;
+}
+
+export interface BotPageRenderProps {
+ bot: Bot;
+ tryLink: string;
+}
+
+/**
+ * Template wrapper for bot detail pages
+ * Handles common patterns: bot lookup, fallback, navigation, and layout
+ *
+ * @example
+ * ```tsx
+ * export default function MyBotPage() {
+ * return (
+ *
+ * {({ bot, tryLink }) => (
+ * <>
+ * tryLink} />
+ *
+ *
+ *
+ * >
+ * )}
+ *
+ * );
+ * }
+ * ```
+ */
+export const BotPageTemplate: FC
= ({
+ botSlug,
+ botDisplayName,
+ children,
+ overrideTryLink,
+ className = '',
+ enableHashScrolling = false,
+ showFooter = false,
+}) => {
+ const bot = getBotBySlug(botSlug);
+ const tryLink = overrideTryLink ?? getBotTryLink(bot);
+ const hasScrolledToTop = useRef(false);
+
+ // Handle scroll to section if hash is present in URL
+ useEffect(() => {
+ if (!enableHashScrolling) return;
+
+ const handleHashChange = () => {
+ const hash = window.location.hash;
+ if (hash) {
+ const element = document.querySelector(hash);
+ if (element) {
+ setTimeout(() => {
+ element.scrollIntoView({ behavior: 'smooth' });
+ }, 100);
+ }
+ } else if (!hasScrolledToTop.current) {
+ window.scrollTo(0, 0);
+ hasScrolledToTop.current = true;
+ }
+ };
+
+ handleHashChange();
+ window.addEventListener('hashchange', handleHashChange);
+ return () => window.removeEventListener('hashchange', handleHashChange);
+ }, [enableHashScrolling]);
+
+ // Return fallback if bot or nav config not found
+ if (!bot || !bot.nav) {
+ return ;
+ }
+
+ const { nav } = bot;
+
+ return (
+
+
+
+
+ {children({ bot, tryLink })}
+
+
+ {showFooter && (
+
+ )}
+
+ );
+};
diff --git a/components/shared/index.ts b/components/shared/index.ts
index 190da90..2c3dc29 100644
--- a/components/shared/index.ts
+++ b/components/shared/index.ts
@@ -1,2 +1,3 @@
export { BotSection } from './BotSection';
export { BotNotFoundFallback } from './BotNotFoundFallback';
+export { BotPageTemplate, type BotPageRenderProps } from './BotPageTemplate';
diff --git a/lib/knowledge.ts b/lib/knowledge.ts
index b83c121..8f6585f 100644
--- a/lib/knowledge.ts
+++ b/lib/knowledge.ts
@@ -52,6 +52,22 @@ function calculateReadTime(content: string): string {
return `${minutes} min`;
}
+/**
+ * Sanitize MDX content by fixing problematic patterns
+ * - Escapes `<` followed by numbers (MDX tries to parse as JSX tag)
+ * - Removes broken Unicode characters
+ */
+function sanitizeMdxContent(content: string): string {
+ return content
+ // Escape < followed by numbers (e.g., "<1%" becomes "<1%")
+ // This prevents MDX from interpreting it as JSX
+ .replace(/<(\d)/g, '<$1')
+ // Remove replacement character (U+FFFD) and other broken Unicode
+ .replace(/\uFFFD/g, ' ')
+ // Remove other common problematic Unicode ranges (surrogate pairs)
+ .replace(/[\uD800-\uDFFF]/g, ' ');
+}
+
/**
* Fetch all guides from the knowledge repository
*/
@@ -154,13 +170,16 @@ export async function fetchGuideBySlug(slug: string): Promise {
// Skip unpublished
if (data.published !== true) continue;
+ // Sanitize content to fix broken Unicode characters
+ const sanitizedContent = sanitizeMdxContent(content);
+
return {
metadata: {
slug,
title: data.title || slug,
description: data.description || '',
difficulty: data.difficulty || 'Beginner',
- readTime: data.readTime || calculateReadTime(content),
+ readTime: data.readTime || calculateReadTime(sanitizedContent),
author: data.author,
publishedAt: data.publishedAt || new Date().toISOString().split('T')[0],
updatedAt: data.updatedAt,
@@ -170,8 +189,8 @@ export async function fetchGuideBySlug(slug: string): Promise {
category: data.category || 'getting-started',
published: true,
},
- content,
- tableOfContents: extractTableOfContents(content),
+ content: sanitizedContent,
+ tableOfContents: extractTableOfContents(sanitizedContent),
};
}
@@ -316,12 +335,15 @@ export async function fetchInfrastructureGuideBySlug(
if (data.published !== true) return null;
+ // Sanitize content to fix broken Unicode characters
+ const sanitizedContent = sanitizeMdxContent(content);
+
return {
slug,
title: data.title || slug,
description: data.description || '',
difficulty: data.difficulty || 'Intermediate',
- readTime: data.readTime || calculateReadTime(content),
+ readTime: data.readTime || calculateReadTime(sanitizedContent),
publishedAt: data.publishedAt || new Date().toISOString().split('T')[0],
tags: data.tags || [],
category: 'infrastructure',
@@ -329,8 +351,8 @@ export async function fetchInfrastructureGuideBySlug(
comparisonType: data.comparisonType || 'tools',
options: data.options || [],
recommendation: data.recommendation,
- content,
- tableOfContents: extractTableOfContents(content),
+ content: sanitizedContent,
+ tableOfContents: extractTableOfContents(sanitizedContent),
};
} catch (error) {
console.info(`Failed to fetch infrastructure guide ${slug}:`, error);