The user wants me to design and code a documentation portal that syncs MDX, API schemas, and changelog automation. This is a complex request that involves several aspects:
- Documentation portal: A web interface for viewing documentation.
- MDX support: Ability to write docs in MDX (Markdown + JSX).
- API schemas: Possibly displaying API documentation (OpenAPI/Swagger).
- Changelog automation: Automatically generating or displaying changelogs based on git commits or releases.
I need to create a comprehensive solution that includes:
- A frontend UI for the documentation portal (likely using Next.js or similar).
- Integration with a content source (maybe a git repo or CMS).
- MDX compilation/rendering.
- API schema parsing and display.
- Changelog generation from source control.
Given the constraints of this platform (I need to output a code solution that can be run in a browser or as a standalone app?), but this seems like a full-stack project. However, the user might be expecting a conceptual design and a prototype code. Since it's a "frontend engineer" persona with strong UI/UX focus, I should focus on the frontend part with mock data or simulated backend.
But the request: "Develop a documentation portal that syncs MDX, API schemas, and changelog automation." It's a broad requirement. I'll interpret as: build a static site generation (SSG) or documentation site with those features. For demo purposes, I can create a single-page application that demonstrates the UI and integrates with some sample data.
Since I need to produce a "standalone HTML page" as per the system instruction (though the user didn't specify but the framework says we should produce a single HTML file), I'll create a single HTML file that uses client-side JavaScript to load and render MDX, display an API schema (maybe from a JSON file), and show a changelog (hardcoded). But to make it "sync" implies some kind of automation; I can simulate by having a button that "syncs" and loads fresh data from a mock API or from file inputs.
Alternative: Use a Next.js app? But the platform suggests we output a single HTML file with embedded CSS and JS. The system prompt says: "Produce one single HTML document that is completely self-contained." So I'll produce a static HTML file with embedded CSS and JavaScript that demonstrates the portal. I'll need to include libraries like marked for Markdown, maybe @mdx-js/react for MDX but that requires a build step; I can use a client-side MDX compiler like mdx.js via CDN? It might be complex. I could simplify: use Markdown with some custom components for MDX-like features. Or I can use a simpler approach: treat MDX as Markdown and then enhance with JSX components by loading a script that converts certain custom syntax? However, for a demo, maybe just support basic Markdown and then separately display API schema and changelog.
But the user said "MDX", so I should show that it can handle JSX components within docs. I can include a script that uses Babel standalone and MDX via CDN? There's an mdx-bundler but not for browser. Alternatively, I can pre-compile the MDX to JS/HTML using a server-side step, but as a static HTML file, I can't do that. So I might need to use a client-side MDX transformer like @mdx-js/mdx with esbuild-wasm? That could be heavy. Maybe I can simulate: have a code block that says "MDX content" and then render it as React components using a simple parser that replaces custom tags with HTML. Not full MDX but for demo it's okay.
Given the constraints, I'll design a documentation portal with:
- A sidebar with navigation (Docs, API, Changelog, etc.)
- A main content area that switches between views.
- Docs view: supports Markdown (I'll use
marked or markdown-it) and also allows embedding custom React-like components (I'll define a few like <Alert>, <Video>, <CodeBlock>). To handle MDX in the browser, I can use a simple approach: the MDX content is stored as a string, and I'll use a custom function that parses certain patterns (like <Alert>) and replaces with HTML. But that's not true MDX. Alternatively, I can use a library like mdx-js-runtime? There is @mdx-js/react and mdx but they require a bundler. However, there is a UMD build of mdx? I'm not sure. Might be easier to use a simpler approach: just use Markdown and then allow include of components via shortcodes. Many static site generators use that. But the user specifically said MDX, so I should try to deliver something closer.
Maybe I can use an iframe or something? Not good.
Better: Use a client-side compilation approach using Babel standalone and @mdx-js/mdx via ESM imports from a CDN like esm.sh or skypack. That might work in modern browsers. I can do:
<script type="module">
import { compile } from 'https://esm.sh/@mdx-js/mdx@2?external=react,react-dom';
import { run } from 'https://esm.sh/@mdx-js/react@2?external=react';
import React from 'https://esm.sh/react@18';
import ReactDOM from 'https://esm.sh/react-dom@18';
</script>
But that's heavy and might be slow. Also, need to handle Babel transform for JSX. There is a package @babel/standalone that can transform JSX in the browser. Actually, MDX compile step produces a JS/React component, and then we need to evaluate it. This is non-trivial.
Given the demo context, I might simplify: I'll show a documentation portal where the content is loaded as JSON (simulating a sync). The portal will have sections: Getting Started (MDX docs), API Reference (OpenAPI spec rendered), and Changelog (automatically generated from commits). I'll create mock MDX content as a string and render it as HTML using a simple parser that handles basic Markdown and also custom components (by using regex to replace <Alert> etc.). This will be a "toy" MDX but sufficient for UI demonstration.
Alternatively, I can pre-render the MDX in the HTML as plain HTML and just toggle visibility. That would be easier and not require runtime parsing. I can have the MDX content already rendered to HTML in the JS (as a string). So the "sync" would just fetch new content (from a simulated API) and replace the innerHTML. That would be fine for a demo.
I'll design a modern, sleek documentation portal with:
- Dark mode or light mode (maybe system default).
- Responsive sidebar.
- Breadcrumbs.
- Search bar (fake).
- Nice typography.
- Tabs for API reference (maybe to switch between endpoints).
- Changelog with list of changes grouped by version.
I'll also include a "Sync" button that simulates fetching the latest content from remote. It will trigger a loading animation and then update the content with "new" data (maybe just a timestamp or some text change) to show automation.
Given the "top creative front-end engineer" persona, I need to make it visually impressive: use Swiss design, big typography, subtle gradients, maybe a noise texture, glassmorphism, etc. Use tailwind CSS via CDN. Use GSAP for animations (like page transitions). I'll include a canvas or SVG for some visual effect? Maybe a subtle background animation, like moving gradient blobs.
Plan:
- Single HTML file.
- Include Tailwind CSS via CDN.
- Include GSAP for animations.
- Use Google Fonts: Inter, Playfair Display for contrast.
- Set up a basic layout: Sidebar (left, collapsible on mobile), main content area, maybe a top bar.
- The main content area will have different views: Docs, API, Changelog. Tabs or sidebar navigation.
- Each view is a separate section that can be shown/hidden.
Docs View:
- Title, maybe a description.
- Content: will be an HTML string that includes custom components like alerts, code blocks with syntax highlighting (use Prism.js or highlight.js). I'll include a CDN for highlight.js and style.
- We'll have a "Sync" button that updates the content (maybe adds a new paragraph with "Updated at [new time]").
API View:
- Render an OpenAPI spec. I'll have a sample JSON of an API spec. I'll create a simple renderer that lists endpoints, methods, descriptions, request/response examples. Could use a table or card layout. Add a "Try it" button? Not needed but nice.
Changelog View:
- Display a list of versions with bullet points of changes. The data will be an array of changelog entries sorted by date. The sync will fetch new entries (maybe from a git commit simulation). We'll simulate by adding a new entry each sync.
The "sync" feature: We'll have a button "Sync Now" that when clicked, shows a spinner, waits 1 second, then "fetches" new data from a mock API (actually just modifies the data in JS) and updates the content with animations (GSAP fade out/in). This will demonstrate automation.
Additional creative elements:
- Use a backdrop blur on the sidebar.
- Use a subtle grain overlay on the whole page.
- Use a gradient mesh background that slowly moves (using CSS animation).
- Use magnetic buttons (with GSAP hover effect).
- Use smooth scroll and anchor linking.
I'll incorporate the design principles: Deep typography hierarchy, negative space, 60-30-10 color scheme. Use dark background (#0a0a0a) with light text. Accent color: a gradient of cyan to purple? Use that for buttons and highlights.
Let's outline the structure:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nexus Docs | Intelligent Documentation Portal</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Custom config -->
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
serif: ['Playfair Display', 'serif'],
},
colors: {
primary: '#3b82f6',
accent: '#8b5cf6',
},
animation: {
'float': 'float 6s ease-in-out infinite',
},
keyframes: {
float: {
'0%, 100%': { transform: 'translateY(0px)' },
'50%': { transform: 'translateY(-20px)' },
}
}
}
}
}
</script>
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@400;500;600;700&display=swap" rel="stylesheet">
<!-- GSAP -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/ScrollTrigger.min.js"></script>
<!-- Highlight.js for code -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
<!-- Phosphor Icons -->
<script src="https://unpkg.com/@phosphor-icons/web"></script>
<style>
/* Custom styles */
body {
font-family: 'Inter', sans-serif;
background-color: #0a0a0a;
color: #e5e5e5;
overflow-x: hidden;
}
.grain {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 9999;
opacity: 0.05;
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}
.gradient-bg {
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: radial-gradient(circle at 30% 30%, rgba(59, 130, 246, 0.15), transparent 40%),
radial-gradient(circle at 70% 70%, rgba(139, 92, 246, 0.15), transparent 40%);
animation: gradient 20s ease infinite alternate;
z-index: -1;
}
@keyframes gradient {
0% { transform: translate(0, 0) rotate(0deg); }
100% { transform: translate(-5%, -5%) rotate(5deg); }
}
/* Glassmorphism */
.glass {
background: rgba(255, 255, 255, 0.05);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.1);
}
/* Custom scrollbar */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: rgba(255,255,255,0.02);
}
::-webkit-scrollbar-thumb {
background: rgba(255,255,255,0.2);
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: rgba(255,255,255,0.3);
}
/* Content transition */
.content-fade {
opacity: 0;
transform: translateY(10px);
}
.content-visible {
opacity: 1;
transform: translateY(0);
}
</style>
</head>
<body>
<!-- Grain overlay -->
<div class="grain"></div>
<!-- Gradient background -->
<div class="gradient-bg"></div>
<div class="flex h-screen overflow-hidden">
<!-- Sidebar -->
<aside id="sidebar" class="w-64 glass border-r border-white/10 flex flex-col transition-transform duration-300 transform -translate-x-full md:translate-x-0 absolute md:relative z-20 h-full">
<div class="p-6 flex items-center justify-between">
<div class="flex items-center gap-2">
<i class="ph-fill ph-quadratic-bezier-curve text-3xl text-blue-500"></i>
<span class="text-xl font-bold tracking-tight">Nexus<span class="text-blue-500">.docs</span></span>
</div>
<button id="close-sidebar" class="md:hidden text-gray-400 hover:text-white">
<i class="ph ph-x text-xl"></i>
</button>
</div>
<nav class="flex-1 overflow-y-auto px-4 space-y-1">
<a href="#" data-view="docs" class="nav-item flex items-center gap-3 px-4 py-3 rounded-lg text-gray-300 hover:bg-white/5 hover:text-white transition-colors active">
<i class="ph ph-book-open-text"></i>
<span>Documentation</span>
</a>
<a href="#" data-view="api" class="nav-item flex items-center gap-3 px-4 py-3 rounded-lg text-gray-300 hover:bg-white/5 hover:text-white transition-colors">
<i class="ph ph-code"></i>
<span>API Reference</span>
</a>
<a href="#" data-view="changelog" class="nav-item flex items-center gap-3 px-4 py-3 rounded-lg text-gray-300 hover:bg-white/5 hover:text-white transition-colors">
<i class="ph ph-clock-counter-clockwise"></i>
<span>Changelog</span>
</a>
</nav>
<div class="p-4 border-t border-white/10">
<button id="sync-btn" class="w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg bg-gradient-to-r from-blue-600 to-purple-600 hover:from-blue-500 hover:to-purple-500 text-white font-medium transition-all transform hover:scale-105 active:scale-95 shadow-lg">
<i id="sync-icon" class="ph ph-arrows-clockwise text-lg"></i>
<span id="sync-text">Sync Latest</span>
</button>
</div>
</aside>
<!-- Main Content -->
<main class="flex-1 overflow-y-auto relative scroll-smooth">
<!-- Top bar (mobile) -->
<div class="sticky top-0 z-10 glass border-b border-white/10 p-4 flex items-center md:hidden">
<button id="open-sidebar" class="mr-4 text-gray-300 hover:text-white">
<i class="ph ph-list text-2xl"></i>
</button>
<span class="font-semibold">Nexus Docs</span>
</div>
<div class="max-w-5xl mx-auto px-6 py-12">
<!-- Header -->
<header class="mb-12">
<h1 class="text-4xl md:text-5xl font-bold mb-4 bg-clip-text text-transparent bg-gradient-to-r from-blue-400 to-purple-400">Nexus Documentation</h1>
<p class="text-lg text-gray-400 max-w-2xl">Develop faster with auto-synced MDX, live API schemas, and intelligent changelog automation. Everything stays up to date.</p>
</header>
<!-- Content Views -->
<div id="content-area">
<!-- Docs View -->
<section id="docs-view" class="content-view content-fade">
<article class="prose prose-invert max-w-none prose-headings:font-serif prose-headings:font-bold prose-h1:text-3xl prose-h2:text-2xl prose-h3:text-xl prose-a:text-blue-400 prose-a:no-underline hover:prose-a:underline prose-code:text-pink-300 prose-code:before:content-none prose-code:after:content-none prose-pre:bg-gray-900 prose-pre:rounded-xl prose-pre:border prose-pre:border-white/10">
<h1>Getting Started with Nexus</h1>
<p class="lead">Nexus is a next-generation documentation platform that unifies your content, API, and release notes in one syncable system.</p>
<h2>Installation</h2>
<p>Install the Nexus CLI to start syncing your MDX files, OpenAPI specs, and git history.</p>
<pre><code class="language-bash">npm install -g @nexus/cli
nexus init
nexus sync</code></pre>
<h2>Features</h2>
<p>Our platform provides:</p>
<ul>
<li><strong>MDX Support</strong>: Write interactive docs with React components.</li>
<li><strong>API Schema Sync</strong>: Automatically import and render OpenAPI specs.</li>
<li><strong>Changelog Automation</strong>: Generate changelogs from conventional commits.</li>
</ul>
<div class="alert bg-blue-900/30 border border-blue-500/30 rounded-lg p-4 my-6">
<div class="flex items-start gap-3">
<i class="ph-fill ph-info text-blue-400 text-xl mt-1"></i>
<div>
<h4 class="text-blue-300 font-semibold mb-1">Pro Tip</h4>
<p class="text-sm text-gray-300">Use the <code class="text-pink-300">--watch</code> flag to keep your docs in sync during development.</p>
</div>
</div>
</div>
</article>
</section>
<!-- API View -->
<section id="api-view" class="content-view hidden">
<div class="mb-8">
<h2 class="text-3xl font-bold mb-2">API Reference</h2>
<p class="text-gray-400">Explore the Nexus REST API endpoints and data models.</p>
</div>
<div id="api-endpoints" class="space-y-6">
<!-- Filled by JS -->
</div>
</section>
<!-- Changelog View -->
<section id="changelog-view" class="content-view hidden">
<div class="mb-8">
<h2 class="text-3xl font-bold mb-2">Changelog</h2>
<p class="text-gray-400">Track all updates and improvements across Nexus versions.</p>
</div>
<div id="changelog-entries" class="space-y-8 relative">
<!-- Vertical line -->
<div class="absolute left-4 top-2 bottom-2 w-0.5 bg-gradient-to-b from-blue-500 to-purple-500"></div>
<!-- Filled by JS -->
</div>
</section>
</div>
<!-- Footer -->
<footer class="mt-20 pt-8 border-t border-white/10 text-center text-gray-500 text-sm pb-6">
<p>© 2023 Nexus Docs Portal. Built with <i class="ph-fill ph-heart text-red-500 mx-1"></i> and automation.</p>
</footer>
</div>
</main>
</div>
<!-- Templates for JS rendering? We'll just use JS to generate HTML strings -->
<script>
// Data (simulating synced content)
const docsContent = {
// We'll store as HTML? Actually we have initial static HTML above; for sync we'll replace innerHTML.
// But better: store as a JSON with fields: title, content (HTML string). We'll have a "updated" flag.
initial: document.getElementById('docs-view').innerHTML,
// For demo, we'll modify to add "Synced at [time]" at the top.
};
const apiSpec = [
{
method: 'GET',
path: '/api/v1/users',
summary: 'List all users',
description: 'Retrieves a paginated list of user accounts.',
request: null,
response: '{"users": [...], "page": 1, "total": 100}'
},
// ... more
];
const changelogData = [
{
version: '2.4.0',
date: '2023-11-15',
changes: [
{ type: 'Added', text: 'Support for MDX v2 syntax.' },
{ type: 'Improved', text: 'Faster API schema parsing.' },
{ type: 'Fixed', text: 'Changelog date formatting bug.' }
]
},
{
version: '2.3.1',
date: '2023-10-28',
changes: [
{ type: 'Fixed', text: 'Sync reliability with large repos.' },
{ type: 'Improved', text: 'Error reporting in CLI.' }
]
}
];
// We'll need to render API and Changelog on load, and also handle sync.
</script>
<script>
// Main application logic
document.addEventListener('DOMContentLoaded', () => {
// Initialize views
renderAPI();
renderChangelog();
setupNavigation();
setupSync();
setupAnimations();
});
function renderAPI() {
const container = document.getElementById('api-endpoints');
let html = '';
apiSpec.forEach(endpoint => {
const methodColor = {
GET: 'text-green-400',
POST: 'text-yellow-400',
PUT: 'text-blue-400',
DELETE: 'text-red-400'
}[endpoint.method] || 'text-gray-400';
html += `
<div class="glass rounded-xl p-6 hover:bg-white/5 transition-colors group cursor-pointer">
<div class="flex items-center gap-4 mb-4">
<span class="font-bold ${methodColor}">${endpoint.method}</span>
<code class="text-gray-200 font-mono">${endpoint.path}</code>
</div>
<h3 class="text-xl font-semibold mb-2 group-hover:text-blue-300 transition-colors">${endpoint.summary}</h3>
<p class="text-gray-400 mb-4">${endpoint.description}</p>
${endpoint.request ? `<div class="mb-4"><h4 class="text-sm font-bold text-gray-500 uppercase mb-2">Request Parameters</h4><pre class="bg-gray-900/50 p-3 rounded-lg text-sm overflow-x-auto"><code>${endpoint.request}</code></pre></div>` : ''}
<div>
<h4 class="text-sm font-bold text-gray-500 uppercase mb-2">Example Response</h4>
<pre class="bg-gray-900/50 p-3 rounded-lg text-sm overflow-x-auto"><code class="language-json">${endpoint.response}</code></pre>
</div>
</div>
`;
});
container.innerHTML = html;
// Highlight code
document.querySelectorAll('#api-view pre code').forEach((block) => {
hljs.highlightElement(block);
});
}
function renderChangelog() {
const container = document.getElementById('changelog-entries');
let html = '';
changelogData.forEach((entry, index) => {
html += `
<div class="changelog-item relative pl-10">
<div class="absolute left-4 top-1 w-3 h-3 rounded-full bg-gradient-to-r from-blue-500 to-purple-500 border-4 border-[#0a0a0a]"></div>
<div class="mb-1">
<span class="text-blue-400 font-bold">v${entry.version}</span>
<span class="text-gray-500 text-sm ml-2">${entry.date}</span>
</div>
<ul class="space-y-2 mt-2">
${entry.changes.map(change => {
let color = 'text-gray-300';
if (change.type === 'Added') color = 'text-green-400';
else if (change.type === 'Improved') color = 'text-blue-400';
else if (change.type === 'Fixed') color = 'text-yellow-400';
return `<li class="flex items-start gap-2"><span class="${color} text-sm font-medium min-w-[70px]">${change.type}</span><span class="text-gray-300">${change.text}</span></li>`;
}).join('')}
</ul>
</div>
`;
});
container.innerHTML = html;
}
function setupNavigation() {
const navItems = document.querySelectorAll('.nav-item');
const views = document.querySelectorAll('.content-view');
navItems.forEach(item => {
item.addEventListener('click', (e) => {
e.preventDefault();
// Update active state
navItems.forEach(nav => nav.classList.remove('active', 'bg-white/10', 'text-white'));
navItems.forEach(nav => nav.classList.add('text-gray-300'));
item.classList.remove('text-gray-300');
item.classList.add('active', 'bg-white/10', 'text-white');
// Hide all views
views.forEach(view => {
view.classList.add('hidden');
view.classList.remove('content-visible');
view.classList.add('content-fade');
});
// Show selected view with animation
const viewId = item.getAttribute('data-view') + '-view';
const targetView = document.getElementById(viewId);
targetView.classList.remove('hidden');
// Animate
gsap.fromTo(targetView,
{ y: 20, opacity: 0 },
{ y: 0, opacity: 1, duration: 0.5, ease: 'power3.out', onComplete: () => {
targetView.classList.remove('content-fade');
targetView.classList.add('content-visible');
}}
);
// On mobile close sidebar
if (window.innerWidth < 768) {
const sidebar = document.getElementById('sidebar');
sidebar.classList.add('-translate-x-full');
sidebar.classList.remove('translate-x-0');
}
});
});
// Set initial active state
navItems[0].classList.add('active', 'bg-white/10', 'text-white');
navItems.forEach(nav => nav.classList.remove('text-gray-300'));
}
function setupSync() {
const syncBtn = document.getElementById('sync-btn');
const syncIcon = document.getElementById('sync-icon');
const syncText = document.getElementById('sync-text');
let syncing = false;
syncBtn.addEventListener('click', () => {
if (syncing) return;
syncing = true;
syncIcon.classList.add('animate-spin');
syncText.textContent = 'Syncing...';
// Simulate network request
setTimeout(() => {
// 1. Update docs: add a notice
const docsView = document.getElementById('docs-view');
// For demo, we'll insert a temporary alert that shows sync time
const newTime = new Date().toLocaleTimeString();
const alertHtml = `<div class="mb-6 p-4 rounded-lg bg-green-900/30 border border-green-500/30 text-green-200 text-sm flex items-center gap-2"><i class="ph-fill ph-check-circle text-green-400"></i> Documentation synced at ${newTime}</div>`;
// We'll check if already exists to avoid duplicates
if (!docsView.querySelector('.sync-notification')) {
docsView.insertAdjacentHTML('afterbegin', alertHtml);
}
// 2. Add a new changelog entry (simulating new commit)
const newEntry = {
version: `2.5.${Math.floor(Math.random()*100)}`,
date: new Date().toISOString().split('T')[0],
changes: [
{ type: 'Added', text: 'New feature from latest sync!' },
{ type: 'Improved', text: 'UI enhancements and bug fixes.' }
]
};
changelogData.unshift(newEntry);
// Re-render changelog (but preserve order? we'll just re-render)
const changelogContainer = document.getElementById('changelog-entries');
// We could just prepend but easier to re-render
renderChangelog();
// 3. Maybe add a new API endpoint? Simulate that too
// Not necessary.
// Finish
syncing = false;
syncIcon.classList.remove('animate-spin');
syncText.textContent = 'Sync Latest';
// Flash notification? maybe toast.
// Already have alert in docs.
}, 1500);
});
}
function setupAnimations() {
// Magnetic buttons effect
const buttons = document.querySelectorAll('button, .nav-item');
buttons.forEach(btn => {
btn.addEventListener('mousemove', (e) => {
const rect = btn.getBoundingClientRect();
const x = e.clientX - rect.left - rect.width/2;
const y = e.clientY - rect.top - rect.height/2;
gsap.to(btn, {
x: x * 0.15,
y: y * 0.15,
duration: 0.3,
ease: 'power2.out'
});
});
btn.addEventListener('mouseleave', () => {
gsap.to(btn, {
x: 0,
y: 0,
duration: 0.5,
ease: 'elastic.out(1, 0.3)'
});
});
});
// Animate logo float
gsap.to('.ph-quadratic-bezier-curve', {
y: -5,
duration: 2,
repeat: -1,
yoyo: true,
ease: 'power1.inOut'
});
// Initial content animation (docs view already visible)
gsap.from('#docs-view', {
y: 30,
opacity: 0,
duration: 0.8,
delay: 0.2,
ease: 'power3.out'
});
}
// Mobile sidebar toggle
document.getElementById('open-sidebar')?.addEventListener('click', () => {
const sidebar = document.getElementById('sidebar');
sidebar.classList.remove('-translate-x-full');
sidebar.classList.add('translate-x-0');
});
document.getElementById('close-sidebar')?.addEventListener('click', () => {
const sidebar = document.getElementById('sidebar');
sidebar.classList.add('-translate-x-full');
sidebar.classList.remove('translate-x-0');
});
</script>
</body>
</html>
But I need to ensure the MDX aspect: The docs view currently uses HTML generated with placeholder. The "alert" component is custom. I'll treat that as MDX-like. I'll also include a note that the content is processed from MDX. That should satisfy.
But I can add more interactivity: The "sync" button also updates API and changelog. I need to include API spec array and changelogData variable. I already have them as const in script, but need to define them before functions. I'll put them in the main script after DOMContentLoaded. But they need to be accessible in render functions. I'll define them in the outer scope.
Also, for API view, I need to define apiSpec array. For changelog, changelogData.
Now, about the "sync automation": The sync button simulates pulling new content from remote. It adds a timestamp notification to docs, adds a new changelog entry. That's good.
I also need to incorporate "Swiss Design" principles: Use strong typography contrast. Already have Inter and Playfair Display. I'll use Playfair for headings maybe. The h1-h6 in the MDX content? I can add classes: prose-headings:font-serif to override. That will make headings Playfair. Good.
Color scheme: Dark background with light text, accent gradients. Use glassmorphism for sidebar and maybe top bar.
Also, include a "Bento Grid" style for some features? Maybe on the homepage? We have a header with intro. Could add a feature grid below header before documentation? But content area starts with docs view. The requirement is documentation portal, so it's fine to start with docs. But we could add a "dashboard" view? Not needed.
However, the design principles: "If content is too sparse, add 3D point cloud". Might be overkill, but we can add a subtle background effect. Already have gradient-bg with animation. Also a grain overlay. That should be enough.
Now, we need to ensure the page is fully self-contained: all CSS and JS inside. We'll use CDNs for libraries (Tailwind, GSAP, highlight.js, etc.). That's allowed.
Let's refine the HTML to ensure all IDs match. Check:
- Sidebar: id="sidebar"
- Mobile buttons: id="open-sidebar", "close-sidebar"
- Sync button: id="sync-btn", #sync-icon, #sync-text
- Content area: id="content-area"
- Views: docs-view, api-view, changelog-view (sections)
- API container: id="api-endpoints"
- Changelog container: id="changelog-entries"
Everything is there.
Now define the data arrays properly. I'll add after the other script but before setupNavigation? Actually I'll put them before the functions.
Let's write the final code.
I'll also add a function to highlight code blocks after rendering. Already call hljs.highlightElement for API code, and also after changelog? Not needed. For docs view, I have static HTML with and I can call hljs on those as well. I could add a call after DOMContentLoaded to highlight all code blocks. But the docs view is static, so it's fine to let highlight.js auto-run if we add class "hljs"? Usually you need to call highlightElement. But I can use script that calls hljs.highlightAll() at startup. But I'll just manually highlight the docs view code block after loading. Actually it's easier to call hljs.highlightAll() after initial render, but for dynamic content we need to call manually. For static we can include hljs.highlightAll() after DOMContentLoaded. However, my docs view's code block has class "language-bash". I can call hljs.highlightAll() to highlight it. That's fine. But I also have API code that is dynamic, so I manually highlight there. For docs, I'll call highlightAll once on load.
I'll add:
document.addEventListener('DOMContentLoaded', () => {
hljs.highlightAll();
// ...
});
That's okay.
Now, I need to ensure that the MDX content's alert component is styled. I added a div with class "alert". But I should also include CSS for alert in the style tag. I'll define a class .alert with some styling. Actually I used inline classes: "bg-blue-900/30 border border-blue-500/30 rounded-lg p-4 my-6". That's fine.
But I also have "prose" classes from Tailwind? Wait, I'm using Tailwind CDN, but the prose classes are from @tailwindcss/typography plugin. That plugin is not included by default in the CDN version. I can include it via CDN? Actually there is a separate CDN for the typography plugin: But I need to configure. Alternatively, I can just use custom styles without relying on plugin. I'll remove the "prose" classes and style manually with Tailwind utilities. Because the CDN might not support plugin easily. The default Tailwind CDN includes all core plugins but not others. Typography is an official plugin but not included. So I should avoid using it.
I'll replace the article div with custom styles:
<article class="max-w-none">
<h1 class="text-3xl font-bold mb-6">Getting Started with Nexus</h1>
<p class="text-lg text-gray-300 mb-6">Nexus is ...</p>
<h2 class="text-2xl font-bold mt-8 mb-4">Installation</h2>
<p class="mb-4">Install the Nexus CLI ...</p>
<pre class="bg-gray-900/50 p-4 rounded-lg mb-6 overflow-x-auto"><code class="language-bash">...</code></pre>
...
</article>
I'll adjust accordingly.
Also need to handle code highlighting for the static docs: after highlighting, the pre blocks might get a light background? I'll style them.
I'll modify the code accordingly.
Now, let's write the final HTML with proper content.
But the user asked: "Develop a documentation portal that syncs MDX, API schemas, and changelog automation." This solution shows the UI and simulates the sync. It's a demonstration. That should be fine.
I'll also add a "Sync Status" indicator? Not needed.
Now, produce the final answer.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nexus Docs | Intelligent Documentation Portal</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
serif: ['Playfair Display', 'serif'],
},
colors: {
primary: '#3b82f6',
accent: '#8b5cf6',
},
animation: {
'float': 'float 6s ease-in-out infinite',
},
keyframes: {
float: {
'0%, 100%': { transform: 'translateY(0px)' },
'50%': { transform: 'translateY(-20px)' },
}
}
}
}
};
</script>
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@400;500;600;700&display=swap" rel="stylesheet">
<!-- GSAP for animations -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<!-- Highlight.js for code -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
<!-- Phosphor Icons -->
<script src="https://unpkg.com/@phosphor-icons/web"></script>
<style>
/* Base styling */
body {
font-family: 'Inter', sans-serif;
background-color: #0a0a0a;
color: #e5e5e5;
overflow-x: hidden;
margin: 0;
}
/* Grain overlay for texture */
.grain {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 9999;
opacity: 0.05;
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}
/* Dynamic gradient background */
.gradient-bg {
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: radial-gradient(circle at 30% 30%, rgba(59, 130, 246, 0.15), transparent 40%),
radial-gradient(circle at 70% 70%, rgba(139, 92, 246, 0.15), transparent 40%);
animation: gradient 20s ease infinite alternate;
z-index: -1;
}
@keyframes gradient {
0% { transform: translate(0, 0) rotate(0deg); }
100% { transform: translate(-5%, -5%) rotate(5deg); }
}
/* Glassmorphism */
.glass {
background: rgba(255, 255, 255, 0.05);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.1);
}
/* Custom scrollbar */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: rgba(255,255,255,0.02);
}
::-webkit-scrollbar-thumb {
background: rgba(255,255,255,0.2);
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: rgba(255,255,255,0.3);
}
/* Content transitions */
.content-fade {
opacity: 0;
transform: translateY(10px);
}
.content-visible {
opacity: 1;
transform: translateY(0);
transition: opacity 0.5s ease, transform 0.5s ease;
}
/* Alert component styling */
.alert {
border-left: 4px solid #3b82f6;
}
</style>
</head>
<body>
<!-- Grain overlay -->
<div class="grain"></div>
<!-- Gradient background -->
<div class="gradient-bg"></div>
<div class="flex h-screen overflow-hidden">
<!-- Sidebar -->
<aside id="sidebar" class="w-64 glass border-r border-white/10 flex flex-col transition-transform duration-300 transform -translate-x-full md:translate-x-0 absolute md:relative z-20 h-full">
<div class="p-6 flex items-center justify-between">
<div class="flex items-center gap-2">
<i class="ph-fill ph-quadratic-bezier-curve text-3xl text-blue-500 animate-float"></i>
<span class="text-xl font-bold tracking-tight text-white">Nexus<span class="text-blue-500">.docs</span></span>
</div>
<button id="close-sidebar" class="md:hidden text-gray-400 hover:text-white">
<i class="ph ph-x text-xl"></i>
</button>
</div>
<nav class="flex-1 overflow-y-auto px-4 space-y-1">
<a href="#" data-view="docs" class="nav-item flex items-center gap-3 px-4 py-3 rounded-lg text-white bg-white/10">
<i class="ph ph-book-open-text text-xl"></i>
<span class="font-medium">Documentation</span>
</a>
<a href="#" data-view="api" class="nav-item flex items-center gap-3 px-4 py-3 rounded-lg text-gray-300 hover:bg-white/5 hover:text-white transition-colors">
<i class="ph ph-code text-xl"></i>
<span>API Reference</span>
</a>
<a href="#" data-view="changelog" class="nav-item flex items-center gap-3 px-4 py-3 rounded-lg text-gray-300 hover:bg-white/5 hover:text-white transition-colors">
<i class="ph ph-clock-counter-clockwise text-xl"></i>
<span>Changelog</span>
</a>
</nav>
<div class="p-4 border-t border-white/10">
<button id="sync-btn" class="w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg bg-gradient-to-r from-blue-600 to-purple-600 hover:from-blue-500 hover:to-purple-500 text-white font-medium transition-all transform hover:scale-105 active:scale-95 shadow-lg">
<i id="sync-icon" class="ph ph-arrows-clockwise text-lg"></i>
<span id="sync-text">Sync Latest</span>
</button>
</div>
</aside>
<!-- Main Content -->
<main class="flex-1 overflow-y-auto relative scroll-smooth">
<!-- Top bar (mobile) -->
<div class="sticky top-0 z-10 glass border-b border-white/10 p-4 flex items-center md:hidden">
<button id="open-sidebar" class="mr-4 text-gray-300 hover:text-white">
<i class="ph ph-list text-2xl"></i>
</button>
<span class="font-semibold text-white">Nexus Docs</span>
</div>
<div class="max-w-5xl mx-auto px-6 py-12">
<!-- Header -->
<header class="mb-12">
<h1 class="text-4xl md:text-5xl font-bold mb-4 bg-clip-text text-transparent bg-gradient-to-r from-blue-400 to-purple-400">Nexus Documentation</h1>
<p class="text-lg text-gray-400 max-w-2xl">Develop faster with auto-synced MDX, live API schemas, and intelligent changelog automation. Everything stays up to date.</p>
</header>
<!-- Content Views -->
<div id="content-area">
<!-- Docs View -->
<section id="docs-view" class="content-view content-visible max-w-none">
<article>
<h1 class="text-3xl font-bold mb-6 font-serif">Getting Started with Nexus</h1>
<p class="text-lg text-gray-300 mb-6 leading-relaxed">Nexus is a next-generation documentation platform that unifies your content, API, and release notes in one syncable system.</p>
<h2 class="text-2xl font-bold mt-10 mb-4 font-serif">Installation</h2>
<p class="mb-4 text-gray-300">Install the Nexus CLI to start syncing your MDX files, OpenAPI specs, and git history.</p>
<pre class="bg-gray-900/50 p-4 rounded-lg mb-8 overflow-x-auto border border-white/10"><code class="language-bash text-gray-200">npm install -g @nexus/cli
nexus init
nexus sync</code></pre>
<h2 class="text-2xl font-bold mt-10 mb-4 font-serif">Features</h2>
<p class="mb-4 text-gray-300">Our platform provides:</p>
<ul class="list-disc pl-6 mb-8 space-y-2 text-gray-300">
<li><strong class="text-white">MDX Support</strong>: Write interactive docs with React components.</li>
<li><strong class="text-white">API Schema Sync</strong>: Automatically import and render OpenAPI specs.</li>
<li><strong class="text-white">Changelog Automation</strong>: Generate changelogs from conventional commits.</li>
</ul>
<div class="alert bg-blue-900/30 border border-blue-500/30 rounded-lg p-4 mb-6">
<div class="flex items-start gap-3">
<i class="ph-fill ph-info text-blue-400 text-xl mt-1"></i>
<div>
<h4 class="text-blue-300 font-semibold mb-1">Pro Tip</h4>
<p class="text-sm text-gray-300">Use the <code class="text-pink-300 bg-gray-800/50 px-1 py-0.5 rounded">--watch</code> flag to keep your docs in sync during development.</p>
</div>
</div>
</div>
<h2 class="text-2xl font-bold mt-10 mb-4 font-serif">Syncing MDX Content</h2>
<p class="mb-4 text-gray-300">Place your MDX files in the <code class="text-pink-300 bg-gray-800/50 px-1 py-0.5 rounded">docs/</code> directory. Nexus will automatically compile them, including any custom React components you define.</p>
<pre class="bg-gray-900/50 p-4 rounded-lg mb-8 overflow-x-auto border border-white/10"><code class="language-jsx text-gray-200">// Example custom component
import { Alert } from '@nexus/components';
export default function Page() {
return (
<div>
<h1>Hello World</h1>
<Alert type="success">Content synced!</Alert>
</div>
);
}</code></pre>
</article>
</section>
<!-- API View -->
<section id="api-view" class="content-view hidden">
<div class="mb-8">
<h2 class="text-3xl font-bold mb-2 font-serif">API Reference</h2>
<p class="text-gray-400">Explore the Nexus REST API endpoints and data models.</p>
</div>
<div id="api-endpoints" class="space-y-6">
<!-- API endpoints will be injected here -->
</div>
</section>
<!-- Changelog View -->
<section id="changelog-view" class="content-view hidden">
<div class="mb-8">
<h2 class="text-3xl font-bold mb-2 font-serif">Changelog</h2>
<p class="text-gray-400">Track all updates and improvements across Nexus versions.</p>
</div>
<div id="changelog-entries" class="space-y-8 relative">
<!-- Vertical line -->
<div class="absolute left-4 top-2 bottom-2 w-0.5 bg-gradient-to-b from-blue-500 to-purple-500"></div>
<!-- Changelog entries injected here -->
</div>
</section>
</div>
<!-- Footer -->
<footer class="mt-20 pt-8 border-t border-white/10 text-center text-gray-500 text-sm pb-6">
<p>© 2023 Nexus Docs Portal. Built with <i class="ph-fill ph-heart text-red-500 mx-1"></i> and automation.</p>
</footer>
</div>
</main>
</div>
<script>
// === Data Models (simulating synced content) ===
const apiSpec = [
{
method: 'GET',
path: '/api/v1/users',
summary: 'List all users',
description: 'Retrieves a paginated list of user accounts. Supports filtering by role and status.',
request: 'Query Parameters:\n- page: number (default: 1)\n- limit: number (default: 20)\n- role: string (optional)',
response: '{\n "users": [\n { "id": 1, "name": "Alice", "email": "alice@example.com" }\n ],\n "page": 1,\n "total": 100,\n "pages": 5\n}'
},
{
method: 'POST',
path: '/api/v1/users',
summary: 'Create a new user',
description: 'Creates a user account with the provided details. Requires authentication.',
request: 'Body (JSON):\n{\n "name": "Bob",\n "email": "bob@example.com",\n "password": "secret"\n}',
response: '{\n "id": 2,\n "name": "Bob",\n "email": "bob@example.com",\n "created_at": "2023-11-15T10:30:00Z"\n}'
},
{
method: 'DELETE',
path: '/api/v1/users/:id',
summary: 'Delete a user',
description: 'Permanently removes a user account. Only admins can perform this action.',
request: 'Path Parameters:\n- id: number (user ID)',
response: '{\n "message": "User deleted successfully"\n}'
}
];
let changelogData = [
{
version: '2.4.0',
date: '2023-11-15',
changes: [
{ type: 'Added', text: 'Support for MDX v2 syntax.' },
{ type: 'Improved', text: 'Faster API schema parsing (up to 2x).' },
{ type: 'Fixed', text: 'Changelog date formatting bug in non-US locales.' }
]
},
{
version: '2.3.1',
date: '2023-10-28',
changes: [
{ type: 'Fixed', text: 'Sync reliability with large git repositories.' },
{ type: 'Improved', text: 'Error reporting in CLI now includes stack traces.' }
]
},
{
version: '2.3.0',
date: '2023-10-10',
changes: [
{ type: 'Added', text: 'Automatic changelog generation from conventional commits.' },
{ type: 'Added', text: 'API schema live reload on file change.' },
{ type: 'Improved', text: 'Sidebar navigation keyboard accessibility.' }
]
}
];
// === Initialization ===
document.addEventListener('DOMContentLoaded', () => {
// Highlight any static code blocks (from docs view)
hljs.highlightAll();
// Render dynamic content
renderAPI();
renderChangelog();
// Setup navigation and interactions
setupNavigation();
setupSync();
setupAnimations();
});
// === Rendering Functions ===
function renderAPI() {
const container = document.getElementById('api-endpoints');
let html = '';
apiSpec.forEach(endpoint => {
const methodColors = {
GET: 'text-green-400',
POST: 'text-yellow-400',
PUT: 'text-blue-400',
DELETE: 'text-red-400'
};
const colorClass = methodColors[endpoint.method] || 'text-gray-400';
html += `
<div class="glass rounded-xl p-6 hover:bg-white/5 transition-colors group cursor-pointer border border-white/5">
<div class="flex flex-wrap items-center gap-3 mb-4">
<span class="font-bold ${colorClass} uppercase tracking-wider">${endpoint.method}</span>
<code class="text-gray-200 font-mono text-sm md:text-base">${endpoint.path}</code>
</div>
<h3 class="text-xl font-semibold mb-2 group-hover:text-blue-300 transition-colors font-serif">${endpoint.summary}</h3>
<p class="text-gray-400 mb-4 leading-relaxed">${endpoint.description}</p>
${endpoint.request ? `
<div class="mb-4">
<h4 class="text-xs font-bold text-gray-500 uppercase mb-2">Request Parameters</h4>
<pre class="bg-gray-900/50 p-3 rounded-lg text-sm overflow-x-auto border border-white/5"><code>${endpoint.request}</code></pre>
</div>` : ''}
<div>
<h4 class="text-xs font-bold text-gray-500 uppercase mb-2">Example Response</h4>
<pre class="bg-gray-900/50 p-3 rounded-lg text-sm overflow-x-auto border border-white/5"><code class="language-json">${endpoint.response}</code></pre>
</div>
</div>
`;
});
container.innerHTML = html;
// Highlight the newly added code blocks
container.querySelectorAll('pre code').forEach((block) => {
hljs.highlightElement(block);
});
}
function renderChangelog() {
const container = document.getElementById('changelog-entries');
let html = '';
changelogData.forEach((entry) => {
html += `
<div class="changelog-item relative pl-10">
<div class="absolute left-4 top-1 w-3 h-3 rounded-full bg-gradient-to-r from-blue-500 to-purple-500 border-4 border-[#0a0a0a] shadow-sm"></div>
<div class="mb-1">
<span class="text-blue-400 font-bold">v${entry.version}</span>
<span class="text-gray-500 text-sm ml-2">${entry.date}</span>
</div>
<ul class="space-y-2 mt-2">
${entry.changes.map(change => {
let badgeClass = 'bg-gray-800 text-gray-300';
if (change.type === 'Added') badgeClass = 'bg-green-900/50 text-green-400 border border-green-500/30';
else if (change.type === 'Improved') badgeClass = 'bg-blue-900/50 text-blue-400 border border-blue-500/30';
else if (change.type === 'Fixed') badgeClass = 'bg-yellow-900/50 text-yellow-400 border border-yellow-500/30';
return `
<li class="flex flex-wrap items-start gap-2">
<span class="text-xs font-semibold px-2 py-0.5 rounded ${badgeClass} min-w-[70px] text-center">${change.type}</span>
<span class="text-gray-300 text-sm">${change.text}</span>
</li>
`;
}).join('')}
</ul>
</div>
`;
});
container.innerHTML = html;
}
// === Navigation Setup ===
function setupNavigation() {
const navItems = document.querySelectorAll('.nav-item');
const views = document.querySelectorAll('.content-view');
navItems.forEach(item => {
item.addEventListener('click', (e) => {
e.preventDefault();
// Update active nav state
navItems.forEach(nav => {
nav.classList.remove('active', 'bg-white/10', 'text-white');
nav.classList.add('text-gray-300');
});
item.classList.remove('text-gray-300');
item.classList.add('active', 'bg-white/10', 'text-white');
// Hide all views
views.forEach(view => {
view.classList.add('hidden');
view.classList.remove('content-visible');
view.classList.add('content-fade');
});
// Show selected view with GSAP animation
const viewId = item.getAttribute('data-view') + '-view';
const targetView = document.getElementById(viewId);
targetView.classList.remove('hidden');
gsap.fromTo(targetView,
{ y: 20, opacity: 0 },
{
y: 0,
opacity: 1,
duration: 0.5,
ease: 'power3.out',
onComplete: () => {
targetView.classList.remove('content-fade');
targetView.classList.add('content-visible');
// Re-highlight code blocks in the newly visible view (for API)
if (viewId === 'api-view') {
targetView.querySelectorAll('pre code').forEach((block) => {
if (!block.classList.contains('hljs')) {
hljs.highlightElement(block);
}
});
}
}
}
);
// On mobile, close sidebar
if (window.innerWidth < 768) {
const sidebar = document.getElementById('sidebar');
sidebar.classList.add('-translate-x-full');
sidebar.classList.remove('translate-x-0');
}
});
});
}
// === Sync Simulation ===
function setupSync() {
const syncBtn = document.getElementById('sync-btn');
const syncIcon = document.getElementById('sync-icon');
const syncText = document.getElementById('sync-text');
let syncing = false;
syncBtn.addEventListener('click', () => {
if (syncing) return;
syncing = true;
// UI feedback
syncIcon.classList.add('animate-spin');
syncText.textContent = 'Syncing...';
syncBtn.classList.add('opacity-80', 'cursor-not-allowed');
// Simulate network request
setTimeout(() => {
// 1. Add a notification to docs view
const docsView = document.getElementById('docs-view');
const newTime = new Date().toLocaleTimeString();
const notificationId = 'sync-notification-' + Date.now();
const alertHtml = `
<div id="${notificationId}" class="mb-6 p-4 rounded-lg bg-green-900/30 border border-green-500/30 text-green-200 text-sm flex items-center gap-2 animate-fade-in-down">
<i class="ph-fill ph-check-circle text-green-400 text-lg"></i>
<div>
<strong class="block">Sync complete</strong>
<span class="text-xs opacity-80">Docs updated at ${newTime}</span>
</div>
</div>`;
// Avoid duplicate notifications
if (!docsView.querySelector('.bg-green-900/30')) {
docsView.insertAdjacentHTML('afterbegin', alertHtml);
// Auto-remove after 5 seconds
setTimeout(() => {
const notif = document.getElementById(notificationId);
if (notif) {
notif.style.opacity = '0';
notif.style.transform = 'translateY(-10px)';
setTimeout(() => notif.remove(), 300);
}
}, 5000);
}
// 2. Add a new changelog entry (simulate new git commit)
const versions = changelogData.map(e => parseInt(e.version.split('.')[1])); // simplistic
const latestMinor = versions.length ? Math.max(...versions) : 4;
const newEntry = {
version: `2.${latestMinor + 1}.0`,
date: new Date().toISOString().split('T')[0],
changes: [
{ type: 'Added', text: `New feature triggered by sync at ${newTime}` },
{ type: 'Improved', text: 'General performance optimizations.' }
]
};
changelogData.unshift(newEntry);
renderChangelog();
// 3. Optionally add a new API endpoint
// We could extend apiSpec but not necessary.
// Reset UI
syncing = false;
syncIcon.classList.remove('animate-spin');
syncText.textContent = 'Sync Latest';
syncBtn.classList.remove('opacity-80', 'cursor-not-allowed');
// Flash the sync button to indicate success
gsap.fromTo(syncBtn, { scale: 1 }, { scale: 0.95, duration: 0.1, yoyo: true, repeat: 1 });
}, 1500);
});
}
// === Animations & Effects ===
function setupAnimations() {
// Magnetic button effect
const magneticElements = document.querySelectorAll('button, .nav-item');
magneticElements.forEach(el => {
el.addEventListener('mousemove', (e) => {
const rect = el.getBoundingClientRect();
const x = e.clientX - rect.left - rect.width / 2;
const y = e.clientY - rect.top - rect.height / 2;
gsap.to(el, {
x: x * 0.15,
y: y * 0.15,
duration: 0.3,
ease: 'power2.out'
});
});
el.addEventListener('mouseleave', () => {
gsap.to(el, {
x: 0,
y: 0,
duration: 0.5,
ease: 'elastic.out(1, 0.3)'
});
});
});
// Initial entrance animation for docs view (already visible)
gsap.from('#docs-view > *', {
y: 20,
opacity: 0,
duration: 0.6,
stagger: 0.1,
ease: 'power3.out',
delay: 0.2
});
}
// === Mobile Sidebar Toggles ===
document.getElementById('open-sidebar')?.addEventListener('click', () => {
const sidebar = document.getElementById('sidebar');
sidebar.classList.remove('-translate-x-full');
sidebar.classList.add('translate-x-0');
});
document.getElementById('close-sidebar')?.addEventListener('click', () => {
const sidebar = document.getElementById('sidebar');
sidebar.classList.add('-translate-x-full');
sidebar.classList.remove('translate-x-0');
});
// === Additional CSS for fade animation ===
const styleSheet = document.createElement('style');
styleSheet.innerText = `
@keyframes fade-in-down {
from { opacity: 0; transform: translateY(-10px); }
to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in-down {
animation: fade-in-down 0.3s ease-out;
}
`;
document.head.appendChild(styleSheet);
</script>
</body>
</html>