fix(navbar): eliminate hardcoded names and make navbar and categories 100% dynamic JSON-driven
This commit is contained in:
@@ -35,11 +35,14 @@
|
||||
"header": [
|
||||
{
|
||||
"label": { "en": "Tools", "hi": "टूल्स" },
|
||||
"href": "/tools"
|
||||
"href": "/tools",
|
||||
"hasDropdown": true,
|
||||
"badge": "14 tools"
|
||||
},
|
||||
{
|
||||
"label": { "en": "Apps", "hi": "ऐप्स" },
|
||||
"href": "/apps"
|
||||
"href": "/apps",
|
||||
"badge": "iOS · Mac"
|
||||
},
|
||||
{
|
||||
"label": { "en": "Pricing", "hi": "मूल्य निर्धारण" },
|
||||
@@ -51,8 +54,18 @@
|
||||
}
|
||||
],
|
||||
"cta": {
|
||||
"label": { "en": "Get the App", "hi": "ऐप प्राप्त करें" },
|
||||
"href": "/apps"
|
||||
"label": { "en": "Try Tools Free", "hi": "टूल्स मुफ्त आज़माएं" },
|
||||
"href": "/tools"
|
||||
},
|
||||
"toolsDropdown": {
|
||||
"viewAllText": {
|
||||
"en": "Explore all studio tools",
|
||||
"hi": "सभी स्टूडियो टूल्स देखें"
|
||||
},
|
||||
"tagline": {
|
||||
"en": "Instant client GPU trial · Zero retention",
|
||||
"hi": "त्वरित क्लाइंट जीपीयू परीक्षण · शून्य प्रतिधारण"
|
||||
}
|
||||
}
|
||||
},
|
||||
"footer": {
|
||||
|
||||
+9
-2
@@ -1,7 +1,7 @@
|
||||
import type { Metadata } from 'next';
|
||||
import { Poppins, Inter, JetBrains_Mono } from 'next/font/google';
|
||||
import './globals.css';
|
||||
import { getSiteConfig } from '@/lib/config/loader';
|
||||
import { getSiteConfig, getAllCategories, getAllTools } from '@/lib/config/loader';
|
||||
import { Navbar } from '@/components/ui/Navbar';
|
||||
import { Footer } from '@/components/ui/Footer';
|
||||
import { SmoothScrollProvider } from '@/components/ui/SmoothScrollProvider';
|
||||
@@ -70,6 +70,8 @@ export default function RootLayout({
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const config = getSiteConfig();
|
||||
const categories = getAllCategories();
|
||||
const tools = getAllTools();
|
||||
const siteUrl = process.env.SITE_URL || config.seo.siteUrl || 'http://localhost:3000';
|
||||
|
||||
// Root Schema.org JSON-LD for Organization & WebSite
|
||||
@@ -96,7 +98,12 @@ export default function RootLayout({
|
||||
<body className="min-h-screen flex flex-col antialiased bg-paper text-ink relative font-sans overflow-x-clip">
|
||||
<SmoothScrollProvider>
|
||||
<a href="#main-content" className="skip-link">Skip to main content</a>
|
||||
<Navbar config={config} currentLocale="en" />
|
||||
<Navbar
|
||||
config={config}
|
||||
currentLocale="en"
|
||||
categories={categories}
|
||||
totalToolsCount={tools.length}
|
||||
/>
|
||||
<main id="main-content" className="flex-1">{children}</main>
|
||||
<Footer config={config} currentLocale="en" />
|
||||
</SmoothScrollProvider>
|
||||
|
||||
@@ -148,32 +148,27 @@ const CATEGORY_THEMES: Record<
|
||||
icon: React.ReactNode;
|
||||
color: string;
|
||||
badgeBg: string;
|
||||
description: string;
|
||||
}
|
||||
> = {
|
||||
'portrait-retouch': {
|
||||
icon: <Smile className="w-4 h-4 text-rose-500" />,
|
||||
color: 'text-rose-600',
|
||||
badgeBg: 'bg-rose-500/10 text-rose-700 border-rose-500/20',
|
||||
description: 'Sub-pore blemish removal, enamel whitening, redness clearing, and radiant studio lighting.',
|
||||
},
|
||||
'restoration': {
|
||||
icon: <Sparkles className="w-4 h-4 text-indigo-500" />,
|
||||
color: 'text-indigo-600',
|
||||
badgeBg: 'bg-indigo-500/10 text-indigo-700 border-indigo-500/20',
|
||||
description: 'Super-resolution 4K deblurring, vintage scratch removal, and authentic archival colorization.',
|
||||
},
|
||||
'background-cutout': {
|
||||
icon: <Scissors className="w-4 h-4 text-emerald-500" />,
|
||||
color: 'text-emerald-600',
|
||||
badgeBg: 'bg-emerald-500/10 text-emerald-700 border-emerald-500/20',
|
||||
description: 'P3M deep learning alpha matting separating hair strands, semi-transparent glass, and edges.',
|
||||
},
|
||||
'creative-art': {
|
||||
icon: <Palette className="w-4 h-4 text-amber-500" />,
|
||||
color: 'text-amber-600',
|
||||
badgeBg: 'bg-amber-500/10 text-amber-700 border-amber-500/20',
|
||||
description: 'Cel-shaded anime synthesis, vintage Polaroid emulsion borders, and object generative fill.',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -856,8 +851,7 @@ export function ToolGridSection({
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-sm sm:text-base text-ink-2 font-body max-w-2xl mt-1.5 leading-relaxed">
|
||||
{CATEGORY_THEMES[activeCategoryItem.id]?.description ||
|
||||
resolveLocalised(activeCategoryItem.category?.description, locale)}
|
||||
{resolveLocalised(activeCategoryItem.category?.description, locale)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -954,9 +948,7 @@ export function ToolGridSection({
|
||||
const catName = group.category
|
||||
? resolveLocalised(group.category.name, locale)
|
||||
: group.id;
|
||||
const catDesc =
|
||||
theme?.description ||
|
||||
(group.category ? resolveLocalised(group.category.description, locale) : '');
|
||||
const catDesc = group.category ? resolveLocalised(group.category.description, locale) : '';
|
||||
|
||||
return (
|
||||
<div
|
||||
|
||||
@@ -14,50 +14,33 @@ import {
|
||||
Smile,
|
||||
Scissors,
|
||||
Palette,
|
||||
Wand2,
|
||||
ChevronDown,
|
||||
ChevronRight
|
||||
} from 'lucide-react';
|
||||
import { SiteConfig } from '@/types';
|
||||
import { SiteConfig, CategoryItem, resolveLocalised } from '@/types';
|
||||
import { BrandLogo } from './BrandLogo';
|
||||
import { RainbowButton } from '@/components/magicui/rainbow-button';
|
||||
|
||||
interface NavbarProps {
|
||||
config: SiteConfig;
|
||||
currentLocale: string;
|
||||
categories?: CategoryItem[];
|
||||
totalToolsCount?: number;
|
||||
}
|
||||
|
||||
const TOOL_CATEGORIES = [
|
||||
{
|
||||
id: 'portrait-retouch',
|
||||
name: 'Portrait & Retouch',
|
||||
tagline: 'Blemish, teeth whitening & face swap',
|
||||
icon: Smile,
|
||||
href: '/tools#category-portrait-retouch',
|
||||
},
|
||||
{
|
||||
id: 'restoration',
|
||||
name: 'Enhance & Restore',
|
||||
tagline: 'Deblur, 4K resolution & colorize',
|
||||
icon: Sparkles,
|
||||
href: '/tools#category-restoration',
|
||||
},
|
||||
{
|
||||
id: 'background-cutout',
|
||||
name: 'Cutout & Inpaint',
|
||||
tagline: 'Object eraser & background remover',
|
||||
icon: Scissors,
|
||||
href: '/tools#category-background-cutout',
|
||||
},
|
||||
{
|
||||
id: 'creative-art',
|
||||
name: 'Creative & Diffusion',
|
||||
tagline: 'Anime avatar, dress & text-to-image',
|
||||
icon: Palette,
|
||||
href: '/tools#category-creative-art',
|
||||
},
|
||||
];
|
||||
const ICON_MAP: Record<string, React.ComponentType<{ className?: string }>> = {
|
||||
Smile,
|
||||
Sparkles,
|
||||
Scissors,
|
||||
Palette,
|
||||
Wand2,
|
||||
Layers,
|
||||
Smartphone,
|
||||
ShieldCheck,
|
||||
};
|
||||
|
||||
export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
export function Navbar({ config, currentLocale, categories = [], totalToolsCount }: NavbarProps) {
|
||||
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
|
||||
const [scrolled, setScrolled] = useState(false);
|
||||
const [toolsDropdownOpen, setToolsDropdownOpen] = useState(false);
|
||||
@@ -111,19 +94,29 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
};
|
||||
}, [mobileMenuOpen]);
|
||||
|
||||
const navLinks = [
|
||||
{ href: '/', label: 'Home', exact: true },
|
||||
{ href: '/tools', label: 'Tools', badge: '10+', hasDropdown: true },
|
||||
{ href: '/apps', label: 'Apps', badge: 'iOS · Mac' },
|
||||
{ href: '/pricing', label: 'Pricing' },
|
||||
{ href: '/trust', label: 'Trust & privacy' },
|
||||
];
|
||||
// Dynamic Navigation Items from JSON (PRD §5 CFG-01..04)
|
||||
const navLinks = (config.nav?.header || []).map((item) => ({
|
||||
href: item.href,
|
||||
label: resolveLocalised(item.label, currentLocale),
|
||||
badge: item.badge,
|
||||
hasDropdown: item.hasDropdown ?? (item.href === '/tools'),
|
||||
exact: item.href === '/',
|
||||
}));
|
||||
|
||||
const isLinkActive = (href: string, exact?: boolean) => {
|
||||
if (exact) return pathname === href;
|
||||
return pathname.startsWith(href);
|
||||
};
|
||||
|
||||
const ctaLabel = resolveLocalised(config.nav?.cta?.label, currentLocale) || 'Try tools free';
|
||||
const ctaHref = config.nav?.cta?.href || '/tools';
|
||||
const viewAllText = config.nav?.toolsDropdown?.viewAllText
|
||||
? resolveLocalised(config.nav.toolsDropdown.viewAllText, currentLocale)
|
||||
: `Explore all ${totalToolsCount || ''} studio tools`;
|
||||
const dropdownTagline = config.nav?.toolsDropdown?.tagline
|
||||
? resolveLocalised(config.nav.toolsDropdown.tagline, currentLocale)
|
||||
: 'Instant client GPU trial · Zero retention';
|
||||
|
||||
return (
|
||||
<header
|
||||
className={`sticky top-0 left-0 right-0 w-full z-40 motion-safe:transition-[background-color,border-color,box-shadow] duration-200 bg-paper border-b border-rule shadow-xs ${
|
||||
@@ -168,20 +161,24 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
}`} />
|
||||
</Link>
|
||||
|
||||
{/* Tools Dropdown Menu - Sleek, Professional & Minimal */}
|
||||
{/* Tools Dropdown Menu - Sleek, Dynamic JSON-Driven */}
|
||||
{toolsDropdownOpen && (
|
||||
<div
|
||||
className="absolute top-full left-1/2 -translate-x-1/2 pt-2.5 w-[320px] z-50 animate-in fade-in zoom-in-95 duration-150"
|
||||
>
|
||||
<div className="p-2 rounded-2xl bg-paper-hi border border-rule shadow-xl space-y-1">
|
||||
{/* Categories List */}
|
||||
{/* Dynamic Categories List from JSON */}
|
||||
<div className="space-y-0.5">
|
||||
{TOOL_CATEGORIES.map((cat) => {
|
||||
const Icon = cat.icon;
|
||||
{categories.map((cat) => {
|
||||
const Icon = (cat.icon && ICON_MAP[cat.icon]) || Sparkles;
|
||||
const catName = resolveLocalised(cat.name, currentLocale);
|
||||
const catDesc = resolveLocalised(cat.description, currentLocale);
|
||||
const catHref = `/tools#category-${cat.id}`;
|
||||
|
||||
return (
|
||||
<Link
|
||||
key={cat.id}
|
||||
href={cat.href}
|
||||
href={catHref}
|
||||
onClick={() => {
|
||||
setToolsDropdownOpen(false);
|
||||
if (typeof window !== 'undefined' && window.location.pathname.startsWith('/tools')) {
|
||||
@@ -196,12 +193,12 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="font-display font-semibold text-xs text-ink group-hover/item:text-accent transition-colors">
|
||||
{cat.name}
|
||||
{catName}
|
||||
</span>
|
||||
<ChevronRight className="w-3.5 h-3.5 text-muted opacity-0 -translate-x-1 group-hover/item:opacity-100 group-hover/item:translate-x-0 transition-all" />
|
||||
</div>
|
||||
<p className="text-[11px] text-muted truncate font-body">
|
||||
{cat.tagline}
|
||||
{catDesc}
|
||||
</p>
|
||||
</div>
|
||||
</Link>
|
||||
@@ -212,11 +209,11 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
{/* Clean Minimal Footer */}
|
||||
<div className="pt-1.5 mt-1 border-t border-rule/70 px-2.5 py-1">
|
||||
<Link
|
||||
href="/tools"
|
||||
href={link.href}
|
||||
onClick={() => setToolsDropdownOpen(false)}
|
||||
className="text-xs font-semibold text-accent hover:text-accent-hi inline-flex items-center justify-between w-full transition-colors py-1"
|
||||
>
|
||||
<span>Explore all 14 studio tools</span>
|
||||
<span>{viewAllText}</span>
|
||||
<ArrowRight className="w-3.5 h-3.5" />
|
||||
</Link>
|
||||
</div>
|
||||
@@ -254,11 +251,10 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
})}
|
||||
</nav>
|
||||
|
||||
{/* Right CTA Actions */}
|
||||
{/* Right CTA Actions from JSON */}
|
||||
<div className="hidden md:flex items-center gap-3 relative z-20 flex-shrink-0">
|
||||
{/* Rainbow Button CTA */}
|
||||
<RainbowButton href="/tools">
|
||||
<span>Try tools free</span>
|
||||
<RainbowButton href={ctaHref}>
|
||||
<span>{ctaLabel}</span>
|
||||
<ArrowRight className="w-3.5 h-3.5 ml-1 inline" aria-hidden="true" />
|
||||
</RainbowButton>
|
||||
</div>
|
||||
@@ -311,14 +307,17 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
</Link>
|
||||
|
||||
{/* Sub-categories under Tools on mobile drawer */}
|
||||
{link.href === '/tools' && (
|
||||
{link.href === '/tools' && categories.length > 0 && (
|
||||
<div className="pl-3 pr-1 py-1 grid grid-cols-2 gap-1.5">
|
||||
{TOOL_CATEGORIES.map((cat) => {
|
||||
const Icon = cat.icon;
|
||||
{categories.map((cat) => {
|
||||
const Icon = (cat.icon && ICON_MAP[cat.icon]) || Sparkles;
|
||||
const catName = resolveLocalised(cat.name, currentLocale);
|
||||
const catHref = `/tools#category-${cat.id}`;
|
||||
|
||||
return (
|
||||
<Link
|
||||
key={cat.id}
|
||||
href={cat.href}
|
||||
href={catHref}
|
||||
onClick={() => {
|
||||
setMobileMenuOpen(false);
|
||||
if (typeof window !== 'undefined' && window.location.pathname.startsWith('/tools')) {
|
||||
@@ -328,7 +327,7 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
className="flex items-center gap-2 p-2 rounded-xl text-xs text-ink hover:text-accent hover:bg-paper-2 bg-paper-hi/60 border border-rule font-body transition-colors"
|
||||
>
|
||||
<Icon className="w-3.5 h-3.5 text-accent shrink-0" />
|
||||
<span className="truncate font-medium">{cat.name}</span>
|
||||
<span className="truncate font-medium">{catName}</span>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
@@ -341,17 +340,15 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
|
||||
<div className="pt-6 border-t border-rule space-y-3">
|
||||
<RainbowButton
|
||||
href="/tools"
|
||||
href={ctaHref}
|
||||
onClick={() => setMobileMenuOpen(false)}
|
||||
className="w-full text-center"
|
||||
>
|
||||
<span>Explore 10+ studio tools</span>
|
||||
<span>{ctaLabel}</span>
|
||||
<ArrowRight className="w-4 h-4 ml-1 inline" aria-hidden="true" />
|
||||
</RainbowButton>
|
||||
<div className="flex items-center justify-center gap-4 text-xs text-muted font-body">
|
||||
<span>Zero server retention</span>
|
||||
<span>•</span>
|
||||
<span>WebGPU acceleration</span>
|
||||
<span>{dropdownTagline}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -167,7 +167,7 @@ export function getAppById(id: string): AppItem | null {
|
||||
}
|
||||
|
||||
export function getAllCategories(): CategoryItem[] {
|
||||
if (categoriesCache.size > 0) return Array.from(categoriesCache.values());
|
||||
categoriesCache.clear();
|
||||
|
||||
const dir = path.join(CONTENT_DIR, 'collections', 'categories');
|
||||
if (fs.existsSync(dir)) {
|
||||
|
||||
@@ -47,11 +47,17 @@ export interface SiteConfig {
|
||||
label: Localised;
|
||||
href: string;
|
||||
children?: string;
|
||||
badge?: string;
|
||||
hasDropdown?: boolean;
|
||||
}>;
|
||||
cta: {
|
||||
label: Localised;
|
||||
href: string;
|
||||
};
|
||||
toolsDropdown?: {
|
||||
viewAllText?: Localised;
|
||||
tagline?: Localised;
|
||||
};
|
||||
};
|
||||
footer: {
|
||||
copyright: string;
|
||||
|
||||
Reference in New Issue
Block a user