get_topnavbar
Get the complete TopNavBar HTML, including logo, subscription, icons, avatar, and navigation tabs, with all icon paths pre-filled, ready to paste into your project.
Instructions
Returns the COMPLETE TopNavBar HTML ready to paste. Includes both Row 1 (logo, subscription, icons, avatar) and Row 2 (navigation tabs). All icon paths pre-filled.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- api/mcp.ts:660-664 (handler)The handler function for the get_topnavbar tool. It reads the topnavbar.md wiki file via readWikiFile(), extracts the HTML block under the 'Complete HTML' section, rewrites asset paths to point to the CDN, and returns the ready-to-paste HTML.
server.tool("get_topnavbar", "Returns the complete TopNavBar HTML with all icon paths pre-filled as CDN URLs. Includes logo, navigation tabs, search, notification, and avatar. Copy directly into your HTML.", {}, async () => { const content = await readWikiFile("topnavbar.md"); const html = rewriteAssetPaths(extractHtmlBlock(content, "Complete HTML")); return { content: [{ type: "text" as const, text: `## TopNavBar — Complete HTML (copy as-is)\nCDN: ${CDN_BASE}\nLogo: ${CDN_BASE}/assets/icons/logo-log360.svg\nAll icon paths are CDN URLs. Do NOT replace with inline SVG.\n\n\`\`\`html\n${html}\n\`\`\`` }] }; }); - api/mcp.ts:659-664 (registration)The tool registration using createMcpHandler. The tool is named 'get_topnavbar' and is registered with an empty schema (no inputs). The description mentions it returns complete TopNavBar HTML with CDN URLs.
/* 12. get_topnavbar */ server.tool("get_topnavbar", "Returns the complete TopNavBar HTML with all icon paths pre-filled as CDN URLs. Includes logo, navigation tabs, search, notification, and avatar. Copy directly into your HTML.", {}, async () => { const content = await readWikiFile("topnavbar.md"); const html = rewriteAssetPaths(extractHtmlBlock(content, "Complete HTML")); return { content: [{ type: "text" as const, text: `## TopNavBar — Complete HTML (copy as-is)\nCDN: ${CDN_BASE}\nLogo: ${CDN_BASE}/assets/icons/logo-log360.svg\nAll icon paths are CDN URLs. Do NOT replace with inline SVG.\n\n\`\`\`html\n${html}\n\`\`\`` }] }; }); - api/mcp.ts:14-41 (helper)readWikiFile helper — reads wiki .md files from a private GitHub repository with a 5-minute TTL cache. Used by get_topnavbar to fetch topnavbar.md.
async function readWikiFile(filename: string): Promise<string> { const name = filename.endsWith(".md") ? filename : `${filename}.md`; const cached = wikiCache.get(name); if (cached && Date.now() - cached.fetchedAt < WIKI_CACHE_TTL_MS) { return cached.text; } if (!GH_TOKEN) return `[ERROR: ELEGANT_GH_TOKEN env var not set]`; try { // Cache-bust GitHub API with a timestamp parameter on cold miss const url = `https://api.github.com/repos/${PRIVATE_REPO}/contents/${WIKI_PATH}/${name}`; const res = await fetch(url, { headers: { Authorization: `Bearer ${GH_TOKEN}`, Accept: "application/vnd.github.raw+json", "X-GitHub-Api-Version": "2022-11-28", "Cache-Control": "no-cache", }, cache: "no-store" as RequestCache, }); if (!res.ok) return `[Wiki file not found: ${name} (${res.status})]`; const text = await res.text(); wikiCache.set(name, { text, fetchedAt: Date.now() }); return text; } catch (err: any) { return `[GitHub fetch error: ${err.message}]`; } } - api/mcp.ts:44-52 (helper)rewriteAssetPaths helper — rewrites relative asset paths (./assets/, ../assets/, etc.) to point to the CDN base URL. Used by get_topnavbar to transform HTML from the wiki.
function rewriteAssetPaths(html: string): string { // Match all relative forms: ./assets/, assets/, ../assets/, ../../assets/ ... // Covers: src="...", href="...", and any data-* attribute pointing at assets/ // (e.g. data-icon, data-src, data-hover-icon — used by JS for dynamic swaps). return html .replace(/src=(["'])(?:\.\/|(?:\.\.\/)+)?assets\//g, (_m, q) => `src=${q}${CDN_BASE}/assets/`) .replace(/href=(["'])(?:\.\/|(?:\.\.\/)+)?assets\//g, (_m, q) => `href=${q}${CDN_BASE}/assets/`) .replace(/(data-[a-z-]+)=(["'])(?:\.\/|(?:\.\.\/)+)?assets\//g, (_m, attr, q) => `${attr}=${q}${CDN_BASE}/assets/`); } - api/mcp.ts:73-77 (helper)extractHtmlBlock helper — extracts an HTML code block from markdown content, optionally scoped to a specific section heading. Used by get_topnavbar to extract the 'Complete HTML' section from topnavbar.md.
function extractHtmlBlock(content: string, heading?: string): string { const src = heading ? extractSection(content, heading) : content; const match = src.match(/```html\n([\s\S]*?)```/); return match ? match[1].trim() : "[No HTML block found]"; }